# -*- coding: utf-8 -*-
# # author: lawaiter
# # created_time: 2020/08/07
# # brief:笔记应用主业务逻辑


import sys
from datetime import datetime, date, timedelta
from functools import partial

from win10toast import ToastNotifier
from PyQt5.QtWebEngineWidgets import QWebEngineSettings
from PyQt5.QtWidgets import QMainWindow, QApplication, QMessageBox, QListWidgetItem, QWidget, QHBoxLayout, QLabel, \
    QSpacerItem, QSizePolicy, QTreeWidgetItem, QCheckBox, QLineEdit, QPushButton, QMenu, QAction, QTreeWidget, \
    QSystemTrayIcon
from PyQt5.QtCore import QVersionNumber, Qt, QSize, QPoint, QUrl, QFileInfo, QCoreApplication, QThread, QMutex, QTimer, \
    QDateTime
from PyQt5.Qt import QT_VERSION_STR
from PyQt5.QtGui import QIcon, QPixmap, QCursor, QFont, QTextBlockFormat

from widgetWinodws.noteMainWindow import Ui_MainWindow
from widgetWinodws import AddMyListWindow, AddMyNoteOrNoteDirWindow, TaskSubMenuWindow, SetTaskTimerWindow


class ReminderThread(QThread):

    """
    后台自定义的线程
    启动一个定时器，每隔1分钟，检查任务里面是否有到任务时间需要提醒的
    """

    def __init__(self):
        super().__init__()
        self.timerReminder = QTimer()
        self.timerReminder.start(60000)

    def run(self):
        # 设置今日清单日期信息
        mainWindow.label_2.setText(str(datetime.now().day))
        self.timerReminder.timeout.connect(self.reminding)

    def reminding(self):
        self.currentTimeString = QDateTime.currentDateTime().toString("yyyy-MM-dd ddd hh:mm")
        # 今日清单
        if mainWindow.label_7.text() == "今日":
            for i in Data["today"]:
                for a in i["task"]:
                    if a["taskTime"] == self.currentTimeString and a["taskName"] == mainWindow.label_12.text():
                        tp.showMessage(a["taskName"], self.currentTimeString, icon=1)
        # 最近七天清单
        elif mainWindow.label_7.text() == "最近7天":
            for i in Data["recent"]:
                for a in i["task"]:
                    if a["taskTime"] == self.currentTimeString and a["taskName"] == mainWindow.label_12.text():
                        tp.showMessage(a["taskName"], self.currentTimeString, icon=1)
        # 自定义清单列表中删除任务后，将数据中的任务数量减一，再重新赋值给清单列表
        else:
            for i in Data["list"]:
                for a in i["task"]:
                    if a["taskTime"] == self.currentTimeString and a["taskName"] == mainWindow.label_12.text():
                        tp.showMessage(a["taskName"], self.currentTimeString, icon=1)


class MyQLineEdit(QLineEdit):

    """
    自定义文本输入框
    实现回车后添加子任务功能
    """

    global Data

    def __init__(self, parent=None, data=None):
        super(MyQLineEdit, self).__init__(parent)
        self.data = data
        self.setStyleSheet(
            "font: 10pt \"微软雅黑\"; "
            "background-color: rgb(127, 127, 127, 0);"
            "border: none;"
        )
        self.setFixedSize(150, 25)
        self.setPlaceholderText("输入子任务，回车")
        self.originalSubTaskName = ""
        # 信号与槽函数，输入新的子任务后回车，自动新增子任务控件并添加子任务数据，同步或者新建后的原始子任务名称
        self.returnPressed.connect(partial(self.addSubTaskByEnter, Data))
        self.returnPressed.connect(self.getOriginalSubTaskName)
        # 输入框中的子任务文本变化，自动修改子任务数据
        self.textChanged.connect(partial(self.addSubTaskData, Data))

    def getOriginalSubTaskName(self):
        self.originalSubTaskName = self.text()

    def addSubTaskData(self, data):

        """
        槽函数
        子任务文本框中的文本一变化，就实时修改子任务名称
        :param data:
        :return:
        """

        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == mainWindow.label_12.text():
                    for a in i["subTask"]:
                        # 如果当前修改的子任务所在索引与数据中子任务索引一致的话
                        if a["subTaskName"] == self.originalSubTaskName:
                            a["subTaskName"] = self.text()
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == mainWindow.label_12.text():
                    for a in i["subTask"]:
                        if a["subTaskName"] == self.originalSubTaskName:
                            a["subTaskName"] = self.text()
        else:
            for i in data["list"]:
                for a in i["task"]:
                    if a["taskName"] == mainWindow.label_12.text():
                        for b in a["subTask"]:
                            if b["subTaskName"] == self.originalSubTaskName:
                                b["subTaskName"] = self.text()

    def addSubTaskByEnter(self, data):

        """
        槽函数
        点击任务详细界面中的添加子任务按钮，添加一条子任务
        :return:
        """

        global mainWindow

        # # 循环查找当前子任务列表中的所有的Item，存在空白子任务就停止使用添加子任务按钮
        # for i in range(0, mainWindow.listWidget_4.count()):
        #     if mainWindow.listWidget_4.itemWidget(mainWindow.listWidget_4.item(i)).findChildren(QLineEdit)[
        #         0].text() == "":
        #         mainWindow.label_13.setEnable(False)
        # # 获取信号发射出的控件也就是删除按钮相对于子任务列表的位置
        # buttonpos = mainWindow.sender().mapToGlobal(QPoint(0, 0)) - mainWindow.listWidget_4.mapToGlobal(QPoint(0, 0))
        # # 获取到item对象
        # item = mainWindow.listWidget_4.indexAt(buttonpos)
        # # 获取该对象的索引
        # index = item.row()
        # delItem = mainWindow.listWidget_4.item(index)
        # delSubTaskName = mainWindow.listWidget_4.itemWidget(delItem).findChildren(QLineEdit)[0].text()
        if self.text() == "":
            QMessageBox.information(mainWindow.label_14, "提示信息", "空名称，请重新输入子任务！")
        else:
            # 创建QListWidgetItem对象
            item = QListWidgetItem()
            # 设置QListWidgetItem大小
            item.setSizeHint(QSize(188, 35))
            # 调用上面的函数获取对应
            widget = getSubTaskWidget()
            # 添加item
            mainWindow.listWidget_4.addItem(item)
            # 为item设置widget
            mainWindow.listWidget_4.setItemWidget(item, widget)
            lineedit = widget.findChildren(QLineEdit)[0]
            lineedit.setStyleSheet(
                "font: 10pt \"微软雅黑\"; "
                "background-color: rgb(127, 127, 127, 0);"
                "border: None;"
            )
            lineedit.setFocus()
            # 新增子任务数据
            if mainWindow.label_7.text() == "今日":
                for i in data["today"][0]["task"]:
                    if i["taskName"] == mainWindow.label_12.text():
                        newSubTask = {
                            "index": len(i["subTask"]),
                            "subTaskName": "",
                            "subTaskDoneState": False,
                            "taskParent": i["taskName"]
                        }
                        i["subTask"].append(newSubTask)
                        i["subTaskNum"] = len(i["subTask"])
                        mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(QLabel)[
                            1].setText(str(i["subTaskNum"]))
            elif mainWindow.label_7.text() == "最近7天":
                for i in data["recent"][0]["task"]:
                    if i["taskName"] == mainWindow.label_12.text():
                        newSubTask = {
                            "index": len(i["subTask"]),
                            "subTaskName": "",
                            "subTaskDoneState": False,
                            "taskParent": i["taskName"]
                        }
                        i["subTask"].append(newSubTask)
                        i["subTaskNum"] = len(i["subTask"])
                        mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(QLabel)[
                            1].setText(str(i["subTaskNum"]))
            else:
                for i in data["list"]:
                    for a in i["task"]:
                        if a["taskName"] == mainWindow.label_12.text():
                            newSubTask = {
                                "index": len(a["subTask"]),
                                "subTaskName": "",
                                "subTaskDoneState": False,
                                "taskParent": a["taskName"]
                            }
                            a["subTask"].append(newSubTask)
                            a["subTaskNum"] = len(a["subTask"])
                            mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                QLabel)[
                                1].setText(str(a["subTaskNum"]))
            # 子任务非空白后，还有把添加按钮设置为可用状态
            mainWindow.label_13.setEnabled(True)

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.originalSubTaskName = self.text()
        # 右键按下
        elif event.buttons() == Qt.RightButton:
            pass


class MyQPushButton(QPushButton):
    """
    自定义按钮
    实现点击后删除子任务功能
    """

    def __init__(self, parent=None):
        super(MyQPushButton, self).__init__(parent)
        self.setStyleSheet(
            "border-image: url('./static/image/删除.svg');"
            "width: 20px; height: 20px;"
        )
        # 信号与槽函数，点击后删除子任务
        self.clicked.connect(partial(delSubTask, Data))


class MyQLabel(QLabel):
    """
    自定义按钮
    实现点击后，选中当前的item项，同时删除子任务功能
    """

    def __init__(self, parent=None):
        super(MyQLabel, self).__init__(parent)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setFixedSize(20, 20)
        self.setCursor(QCursor(Qt.PointingHandCursor))
        self.setToolTip("单击出现菜单")

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.setStyleSheet("font: 12pt;")
            # 获取鼠标左键单击的子菜单标签相对窗口的位置，并将子菜单移动到该位置
            self.m_Position = event.globalPos()
            qTaskSubMenuWindow.move(self.m_Position)
            # 获取鼠标左键单击的子菜单标签相对于未完成任务列表的全局位置
            pos = self.m_Position - mainWindow.listWidget_2.mapToGlobal(QPoint(0, 0))
            # 获取单击出现任务子菜单的item所在的行号，并在MyQLabel类中标记
            taskSubMenuWindow.indexNum = mainWindow.listWidget_2.indexAt(pos).row()
            event.accept()
            # 左键单击2个效果
            # 一个是选中item的效果，右侧出现对应的任务详情界面
            # 一个是出现任务子菜单的效果
            showTaskDetailWidgetByMyQLabel(taskSubMenuWindow.indexNum, Data)
            # 任务子菜单已处于打开状态的话，第二次鼠标左键单击就关闭
            if taskSubMenuWindow.isShow:
                taskSubMenuWindowClose()
            else:
                taskSubMenuWindowShow()
        # 右键按下
        elif event.buttons() == Qt.RightButton:
            # 单击右键的话，关闭任务子菜单
            taskSubMenuWindowClose()

    def mouseReleaseEvent(self, QMouseEvent):

        """重载一下鼠标键释放事件"""

        self.setStyleSheet("font: 10pt;")


class MyNote(QMainWindow, Ui_MainWindow):

    """应用主界面业务逻辑"""

    def __init__(self, parent=None):
        super(MyNote, self).__init__(parent)
        self.setupUi(self)
        # 分割线颜色设置
        self.Line_Color = "#6B8E23"
        self.font = QFont()
        self.font.setFamily("黑体")
        self.setWidgetStyle()
        self.__setting()
        self.taskReminder()

    def __setting(self):
        self.setWindowTitle("个人记录系统")
        # 设置程序图标
        self.setWindowIcon(QIcon("./ico.png"))

    def setWidgetStyle(self):

        """
        设置主界面所有控件的样式
        区分部分控件单独设置、全局设置两种
        """

        # 设置左侧列表区域样式，修改可以更改左侧列表透明度
        self.frame.setStyleSheet("background-color: rgb(255, 255, 255, 30); color: white;")
        # 设置左侧列表区域上半部分，修改可以更改左侧列表上半部分透明度
        self.widget.setStyleSheet("background-color: rgb(255, 255, 255, 0); color: white;")
        # 设置左侧列表区域下半部分，修改可以更改左侧列表下半部分透明度
        self.stackedWidget_1.setStyleSheet("background-color: rgb(255, 255, 255, 0);")
        # 设置右侧显示区域样式，修改可以更改左侧显示区域透明度
        self.stackedWidget_2.setStyleSheet("background-color: rgb(255, 255, 255, 150);")
        # 设置右侧显示区域堆叠控件样式，不同的堆叠页面必须修改为同堆叠窗口一致
        self.page_3.setStyleSheet("background-color: rgb(255, 255, 255, 150);")
        self.page_6.setStyleSheet("background-color: rgb(255, 255, 255, 150);")

        # 设置左侧列表用户组成控件下方的水平分割线样式
        self.line_2.setStyleSheet(
            "background-color: rgb(127, 127, 127, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid " + self.Line_Color + ";"
        )
        # 设置我的清单列表下方水平分割线样式
        self.line_5.setStyleSheet(
            "background-color: rgb(127, 127, 127, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid " + self.Line_Color + ";"
        )
        # 设置清单名称图标标签
        self.label_6.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置清单名称标签样式
        self.label_7.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 20pt \"微软雅黑\";"
        )
        # 设置未完成图标样式
        self.label_8.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置未完成标签样式
        self.label_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 12pt \"微软雅黑\";"
        )
        # 设置已完成图标样式
        self.label_10.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置已完成标签样式
        self.label_11.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 12pt \"微软雅黑\";"
        )
        # 设置未完成任务列表样式1
        self.listWidget_2.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置已完成任务列表样式1
        self.listWidget_3.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置右侧垂直分割线样式
        self.line_6.setStyleSheet(
            "background-color: rgb(127, 127, 127, 0);"
            "border-top: 0px;"
            "border-left: 1px solid " + self.Line_Color + ";"
                                                          "border-right: 0px;"
                                                          "border-bottom: 0px;"
        )
        # 设置任务详细界面按钮水平布局下方水平分割线样式
        self.line_7.setStyleSheet(
            "background-color: rgb(127, 127, 127, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid " + self.Line_Color + ";"
        )
        # 设置任务详细界面任务名称标签样式
        self.label_12.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 14pt \"黑体\";"
        )
        # 设置任务详细界面子任务添加图标
        self.label_13.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "border-image: url('./static/image/listIcon/项目添加.svg');"
            "width: 25px;"
            "height: 25px;"
        )
        # 设置任务详细界面任务描述文本编辑框样式
        self.label_14.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "background-color: rgb(127, 127, 127, 30);"
            "font: 10pt \"黑体\";"
            "color: grey;"
            "border: 7px;"
            "border-radius: 5px;"
        )
        # 设置任务详情子任务列表1
        self.listWidget_4.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
        )
        # 设置笔记名称文本输入框样式
        self.label_15.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 18pt \"微软雅黑\"; "
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #708090;"
        )
        # 笔记功能区按钮分区垂直分割线
        self.line_15.setStyleSheet(
            "background-color: rgb(127, 127, 127, 100);"
            "width: 1px;"
            "border: 0;"
        )
        self.line_15_1.setStyleSheet(
            "background-color: rgb(127, 127, 127, 100);"
            "width: 1px;"
            "border: 0;"
        )

        # 笔记功能区按钮设置图标、悬浮效果样式
        self.label_16.setStyleSheet("QPushButton{"
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "border-image: url('./static/image/noteIcon/字体加粗.svg');"
                                    "width: 9px;"
                                    "height: 11px;"
                                    "}"
                                    ":hover{"
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "border-image: url('./static/image/noteIcon/字体加粗选中.svg');"
                                    "width: 9px;"
                                    "height: 11px;"
                                    "}")
        self.label_16_1.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/字体斜体.svg');"
                                      "width: 12px;"
                                      "height: 11px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/字体斜体选中.svg');"
                                      "width: 12px;"
                                      "height: 11px;"
                                      "}")
        self.label_16_2.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h1标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h1标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_3.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h2标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h2标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_4.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h3标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h3标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_5.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h4标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h4标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_6.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h5标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h5标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_7.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_8.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_9.setStyleSheet("QPushButton{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}"
                                      ":hover{"
                                      "background-color: rgb(255, 255, 255, 0);"
                                      "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                      "width: 13px;"
                                      "height: 13px;"
                                      "}")
        self.label_16_10.setStyleSheet("QPushButton{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}"
                                       ":hover{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}")
        self.label_16_11.setStyleSheet("QPushButton{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}"
                                       ":hover{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}")
        self.label_16_12.setStyleSheet("QPushButton{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}"
                                       ":hover{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}")
        self.label_16_13.setStyleSheet("QPushButton{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}"
                                       ":hover{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题选中.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}")
        self.label_16_14.setStyleSheet("QPushButton{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题.svg');"
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}"
                                       ":hover{"
                                       "background-color: rgb(255, 255, 255, 0);"
                                       "border-image: url('./static/image/noteIcon/h6标题选中.svg'); "
                                       "width: 13px;"
                                       "height: 13px;"
                                       "}")

        # 任务时间按钮
        self.pushButton_7.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
            "text-align: center;"
        )
        # 任务重复按钮
        self.pushButton_8.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
        )
        # 任务重要程度按钮
        self.pushButton_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
        )

        # 设置全局的QSS
        self.setStyleSheet(
            ".QPushButton:pressed {"
            "background-color: rgb(127, 127, 127, 0);"
            "}"
            # 用户头像样式
            ".QPushButton#pushButton {"
            "border-image: url('./static/image/user_avatar.jpg');"
            "border-radius: 20px;"
            "background-color: rgb(255, 255, 255, 0);"
            "color: white;"
            "}"
            # 设置同步按钮样式
            ".QPushButton#pushButton_2 {"
            "background-color: rgb(255, 255, 255, 0);"
            "border-image: url('./static/image/同步.svg');"
            "width: 13px;"
            "height: 15px;"
            "}"
            # 设置设置按钮样式
            ".QPushButton#pushButton_3 {"
            "border-image: url('./static/image/设置.svg');"
            "width: 13px;"
            "height: 15px;"
            "}"
            # 设置用户名称样式
            ".QLabel#label {"
            "background-color: rgb(255, 255, 255, 0);"
            "font: 14pt \"黑体\";"
            "}"
            # 设置今日清单按钮
            ".QPushButton#pushButton_4 {"
            "background-color: rgb(255, 255, 255, 0);"
            "text-align: left;"
            "font: 10pt \"黑体\";"
            "}"
            # 设置最近七天清单按钮
            ".QPushButton#pushButton_5 {"
            "background-color: rgb(255, 255, 255, 0);"
            "text-align: left;"
            "font: 10pt \"黑体\";"
            "}"
            # 设置我的清单标签样式
            ".QLabel#label_4 {"
            "background-color: rgb(255, 255, 255, 0);"
            "font: 14pt \"黑体\";"
            "}"
            # 设置我的笔记标签样式
            ".QLabel#label_5 {"
            "background-color: rgb(255, 255, 255, 0);"
            "font: 14pt \"黑体\";"
            "}"
            # 设置我的清单添加按钮样式
            ".QPushButton#pushButton_6 {"
            "border-image: url('./static/image/listIcon/项目添加.svg');"
            "background-color: rgb(255, 255, 255, 0);"
            "width: 30px;"
            "height: 30px;"
            "}"
            # 设置我的清单列表样式
            "QListWidget#listWidget{"
            "background-color: rgb(255, 255, 255, 0);"
            "color: grey;"
            "font: 10pt;"
            "border: 0px;"
            "outline: 0px"
            "}"
            "QListWidget#listWidget::scroll{"
            "background-color: rgb(255, 255, 255, 0);"
            "outline: 0px"
            "}"
            "QListWidget#listWidget::item{"
            "background-color: rgb(255, 255, 255, 0);"
            "}"
            "QListWidget#listWidget::item:hover{"
            "background-color: rgb(127, 127, 127, 30);"
            "width: 200px;"
            "}"
            "QListWidget#listWidget::item:selected{"
            "background-color: rgb(127, 127, 127, 100);"
            "width: 200px;"
            "}"
            # 设置我的清单添加按钮样式
            ".QPushButton#pushButton_comboBox {"
            "border-image: url('./static/image/noteIcon/项目添加.svg');"
            "background-color: rgb(255, 255, 255, 0);"
            "width: 30px;"
            "height: 30px;"
            "}"
            # 设置我的笔记列表样式
            "QTreeWidget {"
            "background-color: rgb(255, 255, 255, 0);"
            "color: grey;"
            "font: 10pt;"
            "border: 0px;"
            "outline: 0px"
            "}"
            "QTreeWidget::scroll {"
            "background-color: rgb(255, 255, 255, 0);"
            "outline: 0px"
            "}"
            "QTreeWidget::item:hover{"
            "background-color: rgb(127, 127, 127, 30);"
            "width: 200px;"
            "}"
            "QTreeWidget::item:selected{"
            "background-color: rgb(127, 127, 127, 100);"
            "width: 200px;"
            "}"
            # 设置清单名称标签样式
            "QLineEdit#lineEdit {"
            "font: 10pt \"微软雅黑\"; "
            "background-color: rgb(127, 127, 127, 100);"
            "border-radius: 7px;"
            "}"
            "QLineEdit#lineEdit:focus {"
            "font: 10pt \"微软雅黑\"; "
            "background-color: white;"
            "border-radius: 7px"
            "}"
            # 设置未完成任务列表样式2
            "QListWidget#listWidget_2 {"
            "background-color: rgb(255, 255, 255, 0);"
            "color: black;"
            "border:0px;"
            "outline: 0px;"
            "}"
            "QListWidget#listWidget_2::scroll {"
            "background-color: rgb(255, 255, 255, 0);"
            "outline: 0px"
            "}"
            "QListWidget#listWidget_2::item {"
            "background-color: rgb(255, 255, 255, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #C0C0C0;"
            "}"
            "QListWidget#listWidget_2::item:hover {"
            "background-color: rgb(90, 170, 255, 50);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #DCDCDC;"
            "}"
            # 设置已完成任务列表样式2
            "QListWidget#listWidget_3 {"
            "background-color: rgb(255, 255, 255, 0);"
            "color: black;"
            "border:0px;"
            "outline: 0px;"
            "}"
            "QListWidget#listWidget_3::scroll {"
            "background-color: rgb(255, 255, 255, 0);"
            "outline: 0px"
            "}"
            "QListWidget#listWidget_3::item {"
            "background-color: rgb(255, 255, 255, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #C0C0C0;"
            "}"
            "QListWidget#listWidget_3::item:hover {"
            "background-color: rgb(90, 170, 255, 50);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #C0C0C0;"
            "}"
            # 设置任务详情子任务列表1
            "QListWidget#listWidget_4{"
            "background-color: rgb(127, 127, 127, 0);"
            "color: black;"
            "border:0px;"
            "outline: 0px;"
            "}"
            "QListWidget#listWidget_4::scroll{"
            "background-color: rgb(127, 127, 127, 0);"
            "outline: 0px"
            "}"
            "QListWidget#listWidget_4::item{"
            "background-color: rgb(127, 127, 127, 0);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #C0C0C0;"
            "}"
            "QListWidget#listWidget_4::item:hover{"
            "background-color: rgb(90, 170, 255, 50);"
            "border-top: 0px;"
            "border-left: 0px;"
            "border-right: 0px;"
            "border-bottom: 1px solid #C0C0C0;"
            "}"
        )

        # 设置今日清单前、最近七天清单前的图标
        self.label_2.setStyleSheet(
            "border-image: url('./static/image/今日.svg');"
            "background-color: rgb(255, 255, 255, 0);"
            "margin: 0 3px 0 3px;"
            "font: 12px \"黑体\";"
            "color: " + self.Line_Color + ";"
                                          "width: 20px;"
                                          "height: 20px;"
        )
        # 设置为今日时间
        self.label_3.setStyleSheet(
            "border-image: url('./static/image/收集箱.svg');"
            "background-color: rgb(255, 255, 255, 0);"
            "font: 10px;"
            "width: 25px;"
            "height: 25px;"
        )

        # 设置同步按钮、设置按钮
        self.pushButton_2.setCursor(QCursor(Qt.PointingHandCursor))
        self.pushButton_3.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置今日清单按钮、最近七天清单按钮
        self.pushButton_4.setFlat(True)
        self.pushButton_5.setFlat(True)
        self.pushButton_4.setCursor(QCursor(Qt.PointingHandCursor))
        self.pushButton_5.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置我的清单添加按钮
        self.pushButton_6.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置我的清单列表
        self.listWidget.setFont(self.font)
        self.listWidget.setObjectName("listwidget_6")
        # 设置右侧的垂直滚动条隐藏
        self.listWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # 设置item中的图标的大小
        self.listWidget.setIconSize(QSize(20, 20))
        # 设置自定义的右键菜单
        self.listWidget.setContextMenuPolicy(Qt.CustomContextMenu)

        # 设置我的笔记添加按钮
        self.pushButton_comboBox.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置清单图标，名称
        self.label_pix = QPixmap("./static/image/项目.svg").scaled(25, 25)
        self.label_6.setPixmap(self.label_pix)
        self.label_7.setText("今日")

        # 设置未完成图标、标签，已完成图标、标签
        self.label_pix = QPixmap("./static/image/下拉.svg").scaled(20, 20)
        self.label_8.setPixmap(self.label_pix)
        self.label_10.setPixmap(self.label_pix)

        # 设置任务时间标签
        self.pushButton_7.setCursor(QCursor(Qt.PointingHandCursor))

        # 任务详细界面任务名称标签样式，设置子任务图标
        self.label_13.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置笔记名称标签样式
        self.label_15.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        # 笔记功能区按钮鼠标手势
        self.label_16.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_1.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_2.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_3.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_4.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_5.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_6.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_7.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_8.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_9.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_10.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_11.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_12.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_13.setCursor(QCursor(Qt.PointingHandCursor))
        self.label_16_14.setCursor(QCursor(Qt.PointingHandCursor))

        # 设置MarkDown编辑器样式
        self.textEdit.setStyleSheet("background: rgb(40, 40, 40 ,255); color: grey; font: 10pt;")
        font = QFont()
        font.setFamily("黑体")
        self.textEdit.setFont(font)
        # 设置编辑器行间距
        cursor = self.textEdit.textCursor()
        textFormat = QTextBlockFormat()
        textFormat.setLineHeight(13, QTextBlockFormat.LineDistanceHeight)
        cursor.setBlockFormat(textFormat)
        self.textEdit.setTextCursor(cursor)

        # 设置MarkDown预览器样式
        self.textView.page().settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)
        self.textView.setContentsMargins(0, 0, 0, 0)
        self.textView.setStyleSheet("padding: -200px -200px 0px 0px; border: 0; ")
        self.textView.setAutoFillBackground(True)
        self.textView.setZoomFactor(0.1)

    def taskReminder(self):

        """创建启动线程"""

        self.thread_1 = ReminderThread()
        self.thread_1.start()


class MyQTreeWidget(QTreeWidget):
    def __init__(self, data=None):
        super(MyQTreeWidget, self).__init__()

        self.setColumnCount(2)  # 共2列
        self.setHeaderLabels(['Key', 'Value'])

        self.rootList = []
        root = self
        self.generateTreeWidget(data, root)

        print(len(self.rootList), self.rootList)

        self.insertTopLevelItems(0, self.rootList)

    def generateTreeWidget(self, data, root):
        if isinstance(data, dict):
            for key in data.keys():
                child = QTreeWidgetItem()
                child.setText(0, key)
                if isinstance(root, QTreeWidget) == False:  # 非根节点，添加子节点
                    root.addChild(child)
                self.rootList.append(child)
                print(key)
                value = data[key]
                self.generateTreeWidget(value, child)
        else:
            root.setText(1, str(data))


if __name__ == "__main__":

    """这是开启高分辨率自适应，只有版本5.6.0以上才支持"""

    # 设置PyQt5版本5.6.0的比较值
    v_compare = QVersionNumber(5, 6, 0)
    # 获取当前的PyQt5的版本
    v_current, _ = QVersionNumber.fromString(QT_VERSION_STR)
    # 如果当前的版本大于5.6.0
    if QVersionNumber.compare(v_current, v_compare) >= 0:
        # 开启分辨率自适应，也就是对于1080P以上的，自适应高分辨率
        QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
        app = QApplication(sys.argv)
    else:
        app = QApplication(sys.argv)

    # 关闭所有窗口,也不关闭应用程序
    QApplication.setQuitOnLastWindowClosed(False)

    # 实例化主界面
    mainWindow = MyNote()

    # 实例化添加清单窗口
    addMyListWindow = AddMyListWindow.Ui_Form()
    qAddMyListWindow = QWidget()
    addMyListWindow.setupUi(qAddMyListWindow)

    # 实例化新建笔记或笔记文件夹窗口
    addMyNoteOrNoteDirWindow = AddMyNoteOrNoteDirWindow.Ui_Form()
    qAddMyNoteOrNoteDirWindow = QWidget()
    addMyNoteOrNoteDirWindow.setupUi(qAddMyNoteOrNoteDirWindow)

    # 实例化任务子菜单界面
    taskSubMenuWindow = TaskSubMenuWindow.Ui_Form()
    qTaskSubMenuWindow = QWidget()
    taskSubMenuWindow.setupUi(qTaskSubMenuWindow)

    # 实例化时间设置界面
    setTaskTimerWindow = SetTaskTimerWindow.Ui_Form()
    qSetTaskTimerWindow = QWidget()
    setTaskTimerWindow.setupUi(qSetTaskTimerWindow)

    # 当前清单下选中任务状态
    CURRENT_TASK_STATE = False

    Data = {
        "userName": "jokery",
        "today": [
            {
                "index": 0,
                "listName": "今日",
                "task": [
                    {
                        "index": 0,
                        "taskCheck": True,
                        "taskName": "开始对接内容",
                        "subTaskNum": 2,
                        "taskLevel": "优先级中等.svg",
                        "taskTime": "2020-08-24",
                        "taskCircle": "每周一次",
                        "taskTags": [],
                        "taskDone": False,
                        "taskFlag": "中等任务",
                        "listParent": "今日",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": False,
                                "taskParent": "开始对接内容"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": False,
                                "taskParent": "开始对接内容"
                            },
                        ],
                    },
                    {
                        "index": 1,
                        "taskCheck": False,
                        "taskName": "制作软件APP",
                        "subTaskNum": 3,
                        "taskLevel": "优先级重要.svg",
                        "taskTime": "2020-8-19",
                        "taskCircle": "",
                        "taskTags": [],
                        "taskDone": False,
                        "taskFlag": "重要任务",
                        "listParent": "今日",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成界面设计",
                                "subTaskDoneState": False,
                                "taskParent": "制作软件APP"
                            },
                            {
                                "index": 1,
                                "subTaskName": "开始研讨会",
                                "subTaskDoneState": True,
                                "taskParent": "制作软件APP"
                            },
                            {
                                "index": 2,
                                "subTaskName": "出差的东西收拾",
                                "subTaskDoneState": False,
                                "taskParent": "制作软件APP"
                            },
                        ],
                    },
                ],
            },
        ],
        "recent": [
            {
                "index": 0,
                "listName": "最近7天",
                "task": [
                    {
                        "index": 0,
                        "taskCheck": True,
                        "taskName": "准备现场",
                        "subTaskNum": 2,
                        "taskLevel": "优先级重要.svg",
                        "taskTime": "2020-08-24",
                        "taskCircle": "每月一次",
                        "taskTags": [],
                        "taskDone": False,
                        "taskFlag": "重要任务",
                        "listParent": "最近7天",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": False,
                                "taskParent": "准备现场"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": True,
                                "taskParent": "准备现场"
                            },
                        ],
                    },
                    {
                        "index": 1,
                        "taskCheck": False,
                        "taskName": "出差准备",
                        "subTaskNum": 3,
                        "taskLevel": "优先级中等.svg",
                        "taskTime": "2020-8-19",
                        "taskCircle": "",
                        "taskTags": [],
                        "taskDone": True,
                        "taskFlag": "中等任务",
                        "listParent": "最近7天",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": False,
                                "taskParent": "出差准备"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": True,
                                "taskParent": "出差准备"
                            },
                            {
                                "index": 2,
                                "subTaskName": "会场清理",
                                "subTaskDoneState": False,
                                "taskParent": "出差准备"
                            },
                        ],
                    },
                ],
            },
        ],
        "list": [
            {
                "index": 0,
                "listName": "工作",
                "taskNum": 2,
                "listColor": "圆形9.svg",
                "task": [
                    {
                        "index": 0,
                        "taskCheck": True,
                        "taskName": "完成物资采购",
                        "subTaskNum": 2,
                        "taskLevel": "优先级重要.svg",
                        "taskTime": "2020-08-24",
                        "taskCircle": "每周一次",
                        "taskTags": [],
                        "taskDone": False,
                        "taskFlag": "重要任务",
                        "listParent": "工作",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": True,
                                "taskParent": "完成物资采购"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": False,
                                "taskParent": "完成物资采购"
                            },
                        ],
                    },
                    {
                        "index": 1,
                        "taskCheck": False,
                        "taskName": "准备会议场所",
                        "subTaskNum": 3,
                        "taskLevel": "优先级中等.svg",
                        "taskTime": "2020-8-19",
                        "taskCircle": "",
                        "taskTags": [],
                        "taskDone": True,
                        "taskFlag": "中等任务",
                        "listParent": "工作",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": True,
                                "taskParent": "准备会议场所"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": True,
                                "taskParent": "准备会议场所"
                            },
                            {
                                "index": 2,
                                "subTaskName": "会场清理",
                                "subTaskDoneState": False,
                                "taskParent": "准备会议场所"
                            },
                        ],
                    },
                ],
            },
            {
                "index": 0,
                "listName": "工作2",
                "taskNum": 2,
                "listColor": "圆形9.svg",
                "task": [
                    {
                        "index": 0,
                        "taskCheck": True,
                        "taskName": "完成物资采购2",
                        "subTaskNum": 2,
                        "taskLevel": "优先级重要.svg",
                        "taskTime": "2020-08-24",
                        "taskCircle": "每周一次",
                        "taskTags": [],
                        "taskDone": False,
                        "taskFlag": "重要任务",
                        "listParent": "工作2",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": True,
                                "taskParent": "完成物资采购2"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": False,
                                "taskParent": "完成物资采购2"
                            },
                        ],
                    },
                    {
                        "index": 1,
                        "taskCheck": False,
                        "taskName": "准备会议场所2",
                        "subTaskNum": 3,
                        "taskLevel": "优先级中等.svg",
                        "taskTime": "2020-8-19",
                        "taskCircle": "",
                        "taskTags": [],
                        "taskDone": True,
                        "taskFlag": "中等任务",
                        "listParent": "工作2",
                        "subTask": [
                            {
                                "index": 0,
                                "subTaskName": "完成对应工作",
                                "subTaskDoneState": True,
                                "taskParent": "准备会议场所2"
                            },
                            {
                                "index": 1,
                                "subTaskName": "准备会场",
                                "subTaskDoneState": True,
                                "taskParent": "准备会议场所2"
                            },
                            {
                                "index": 2,
                                "subTaskName": "会场清理",
                                "subTaskDoneState": False,
                                "taskParent": "准备会议场所2"
                            },
                        ],
                    },
                ],
            },
        ],
    }

    DataNote = {"note":
        [
            {
                "index": 0,
                "noteName": "年度工作",
                "isNote": False,
                "noteContent": "womneiiji",
                "noteParent": "",
                "colorFlag": "标志15.svg",
                "subContent": [
                    {
                        "index": 0,
                        "noteName": "2018年度工作",
                        "isNote": True,
                        "noteContent": "womneiiji",
                        "noteParent": "年度工作",
                        "colorFlag": "",
                        "subContent": [],
                    },
                    {
                        "index": 1,
                        "noteName": "2019年度工作",
                        "isNote": False,
                        "noteContent": "womneiiji",
                        "noteParent": "年度工作",
                        "colorFlag": "标志15.svg",
                        "subContent": [
                            {
                                "index": 0,
                                "noteName": "2019年8月份",
                                "isNote": True,
                                "noteContent": "womneiiji",
                                "noteParent": "2019年度工作",
                                "colorFlag": "",
                                "subContent": [],
                            },
                            {
                                "index": 1,
                                "noteName": "2019年9月份",
                                "isNote": True,
                                "noteContent": "womneiiji",
                                "noteParent": "2019年度工作",
                                "colorFlag": "",
                                "subContent": [],
                            },
                        ],
                    },
                ],
            },
            {
                "index": 1,
                "noteName": "生活计划",
                "isNote": True,
                "noteContent": "womneiiji",
                "noteParent": "",
                "colorFlag": "",
                "subContent": [
                ],
            },
            {
                "index": 2,
                "noteName": "学习计划",
                "isNote": True,
                "noteContent": "womneiiji",
                "noteParent": "",
                "colorFlag": "",
                "subContent": [
                ],
            },
        ],
    }

    """功能函数集合"""


    def undoTaskCheckBox():

        """
        功能函数
        为当前清单每项任务复选框添加信号与槽函数
        :return: 自定义的复选框控件
        """

        taskCheckBox = QCheckBox()
        # 设置未选中和选中状态下的样式图标
        taskCheckBox.setStyleSheet(
            "QCheckBox::indicator:unchecked {"
            "border-image: url('./static/image/listIcon/复选框未选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "color: black;"
            "}"
            "QCheckBox::indicator: checked{ "
            "border-image: url('./static/image/listIcon/复选框选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "}"
        )

        def check_state():
            """
            槽函数
            点击复选框，切换不同的任务分类
            """

            if taskCheckBox.isCheckable():
                undoTaskChanged(Data)

        taskCheckBox.stateChanged.connect(check_state)
        return taskCheckBox


    def doneTaskCheckBox():

        """
        功能函数
        为当前清单每项任务复选框添加信号与槽函数
        :return: 自定义的复选框控件
        """

        taskCheckBox = QCheckBox()
        # 设置未选中和选中状态下的样式图标，已完成的任务清单，默认为选中的复选框
        taskCheckBox.setStyleSheet(
            "QCheckBox::indicator:unchecked {"
            "border-image: url('./static/image/listIcon/复选框选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "color: black;"
            "}"
            "QCheckBox::indicator: checked{ "
            "border-image: url('./static/image/listIcon/复选框未选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "}"
        )

        def check_state():
            """
            槽函数
            点击复选框，切换不同的任务分类
            """

            if taskCheckBox.isCheckable():
                doneTaskChanged(Data)

        taskCheckBox.stateChanged.connect(check_state)
        return taskCheckBox


    def undoSubTaskCheckBox():

        """
        功能函数
        为当前任务下的每项子任务复选框添加信号与槽函数
        :return: 自定义的复选框控件
        """

        taskCheckBox = QCheckBox()
        # 设置未选中和选中状态下的样式图标
        taskCheckBox.setStyleSheet(
            "QCheckBox::indicator:unchecked {"
            "border-image: url('./static/image/listIcon/复选框未选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "color: black;"
            "}"
            "QCheckBox::indicator: checked{ "
            "border-image: url('./static/image/listIcon/复选框选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "}"
        )

        def check_state():
            """
            槽函数
            点击复选框，子任务完成并从列表中删除
            """

            if taskCheckBox.isCheckable():
                undoSubTaskChanged()

        taskCheckBox.stateChanged.connect(check_state)
        return taskCheckBox


    def doneSubTaskCheckBox():

        """
        功能函数
        为当前任务下的每项子任务复选框添加信号与槽函数
        :return: 自定义的复选框控件
        """

        taskCheckBox = QCheckBox()
        # 设置未选中和选中状态下的样式图标，已完成的子任务点击复选框没有任何变化，不能变为未完成，只能删除
        taskCheckBox.setStyleSheet(
            "QCheckBox::indicator:unchecked {"
            "border-image: url('./static/image/listIcon/复选框选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "color: black;"
            "}"
            "QCheckBox::indicator:checked { "
            "border-image: url('./static/image/listIcon/复选框选中.svg');"
            "width: 15px;"
            "height: 15px;"
            "}"
        )
        taskCheckBox.setEnabled(False)

        def check_state():
            """
            槽函数
            点击复选框，完成的子任务不能变为未完成只能删除
            """
            pass

        taskCheckBox.stateChanged.connect(check_state)
        return taskCheckBox


    def getMyListWidget(listname, tasknum="", listcolor="圆形11.svg"):

        """
        功能函数
        添加我的清单中的自定义控件组件
        :param: listname 自定义清单名称
        :return: widgetItem 自定义的清单控件
        """

        # 控件
        widgetItem = QWidget()

        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)

        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()

        # 清单图标
        listImage = QLabel()
        listImage.setFixedSize(17, 17)
        maps = QPixmap("./static/image/项目.svg").scaled(17, 17)
        listImage.setPixmap(maps)
        # 清单名称
        listName = QLabel()
        listName.setAlignment(Qt.AlignLeft | Qt.AlignHCenter)
        listName.setText(listname)
        listName.resize(60, 17)
        # 清单任务数量1
        taskNum = QLabel()
        taskNum.setAlignment(Qt.AlignLeft | Qt.AlignHCenter)
        if taskNum == 0:
            taskNum.setText("")
        else:
            taskNum.setText(str(tasknum))
        # 任务区分
        listFlag = QPushButton()
        listFlag.setFixedSize(10, 10)
        listFlag.setStyleSheet(
            "border-image: url('./static/image/" + listcolor + "');"
                                                               "color: rgb(127, 127, 127, 0);"
        )
        listFlag.setObjectName(listcolor)
        # 空格
        spacer = QSpacerItem(60, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)

        # 添加至水平布局
        layoutItem.addWidget(listImage)
        layoutItem.addWidget(listName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(taskNum)
        layoutItem.addWidget(listFlag)
        layoutMain.addLayout(layoutItem)
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        return widgetItem


    def getUndoTaskWidget(undotaskname, undosubtasknum="", undotasklevel=""):

        """
        功能函数
        添加我的清单中的自定义控件组件
        :param: undotaskname 自定义任务名称
        :return: widgetItem 自定义的清单控件
        """

        # 控件
        widgetItem = QWidget()

        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)

        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()

        # 任务图标
        taskCheckBox = undoTaskCheckBox()
        taskCheckBox.setFixedSize(15, 15)
        # 任务名称
        taskName = QLabel()
        taskName.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        taskName.setText(undotaskname)
        taskName.resize(60, 17)
        # 子任务数量标签
        subTaskNum = QLabel()
        subTaskNum.setAlignment(Qt.AlignCenter)
        subTaskNum.setText(str(undosubtasknum))
        # 任务程度
        taskLevel = QPushButton()
        taskLevel.setStyleSheet(
            "border-image: url('./static/image/listIcon/" + undotasklevel + "');"
                                                                            "width: 13px;"
                                                                            "height: 13px;"
        )
        # 任务子菜单
        taskMenu = MyQLabel()
        taskMenu.setText("...")
        taskMenu.setAlignment(Qt.AlignCenter)
        spacer = QSpacerItem(60, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)

        # 添加至水平布局
        layoutItem.setContentsMargins(5, 0, 5, 0)
        layoutMain.setContentsMargins(0, 0, 0, 0)
        layoutItem.addWidget(taskCheckBox)
        layoutItem.addWidget(taskName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(subTaskNum)
        layoutItem.addWidget(taskLevel)
        layoutItem.addWidget(taskMenu)
        layoutMain.addLayout(layoutItem)
        widgetItem.setStyleSheet(
            "QWidget{height: 80px; color: black; font: 10pt \"黑体\";}"
            "QLabel#taskMenu {font: 10pt \"宋体\";}"
        )
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        return widgetItem


    def getSubTaskWidget():

        """
        功能函数
        根据输入的名称，在任务详细界面添加子任务
        """

        # 控件
        widgetItem = QWidget()

        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)

        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()

        # 任务图标
        taskCheckBox = undoSubTaskCheckBox()
        # 任务名称
        taskName = MyQLineEdit(widgetItem, Data)
        # 任务删除标签
        taskDel = MyQPushButton(widgetItem)
        spacer = QSpacerItem(20, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)
        # 添加至水平布局
        layoutItem.setContentsMargins(5, 0, 5, 0)
        layoutMain.setContentsMargins(0, 0, 0, 0)
        layoutItem.addWidget(taskCheckBox)
        layoutItem.addWidget(taskName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(taskDel)
        layoutMain.addLayout(layoutItem)
        widgetItem.setStyleSheet(
            "QWidget{color: black; font: 8pt \"微软雅黑\";}"
        )
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        return widgetItem


    def showTodayTaskItem(data):

        """
        功能函数
        初始化界面显示今天清单内容
        """

        # 设置任务展示界面题头清单名称
        mainWindow.label_7.setText("今日")
        # 删除任务展示界面内容
        mainWindow.listWidget_2.clear()
        mainWindow.listWidget_3.clear()
        mainWindow.listWidget_4.clear()
        # 删除任务详细界面初始化内容
        # 删除子任务列表
        mainWindow.listWidget_4.clear()
        # 删除任务时间
        mainWindow.pushButton_7.setText("任务时间")
        # 删除任务重复
        mainWindow.pushButton_8.setText("")
        # 删除任务级别
        mainWindow.pushButton_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
            "color: black;"
        )
        mainWindow.pushButton_9.setText("任务级别")
        # 删除任务名称
        mainWindow.label_12.setText("任务名称")

        # 初始化数据，添加清单类控件
        for i in data["today"]:
            for a in i["task"]:
                if a["taskDone"] == False:
                    addUndoTaskItem(a["taskName"], a["subTaskNum"], a["taskLevel"])
                else:
                    addDoneTaskItem(a["taskName"])
        mainWindow.stackedWidget_2.setCurrentIndex(0)


    def showRecentTaskItem(data):

        """
        功能函数
        初始化界面显示今天清单内容
        """

        # 设置任务展示界面题头清单名称
        mainWindow.label_7.setText("最近7天")
        # 删除任务展示界面内容
        mainWindow.listWidget_2.clear()
        mainWindow.listWidget_3.clear()
        mainWindow.listWidget_4.clear()
        # 删除任务详细界面初始化内容
        # 删除子任务列表
        mainWindow.listWidget_4.clear()
        # 删除任务时间
        mainWindow.pushButton_7.setText("任务时间")
        # 删除任务重复
        mainWindow.pushButton_8.setText("")
        # 删除任务级别
        mainWindow.pushButton_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
            "color: black;"
        )
        mainWindow.pushButton_9.setText("任务级别")
        # 删除任务名称
        mainWindow.label_12.setText("任务名称")

        # 初始化数据，添加清单类控件
        for i in data["recent"]:
            for a in i["task"]:
                if a["taskDone"] == False:
                    addUndoTaskItem(a["taskName"], a["subTaskNum"], a["taskLevel"])
                else:
                    addDoneTaskItem(a["taskName"])
        mainWindow.stackedWidget_2.setCurrentIndex(0)


    def showMyListItem(data):

        """
        功能函数
        初始化界面显示我的清单列表
        """

        for i in data["list"]:
            # 创建QListWidgetItem对象
            item = QListWidgetItem()
            # 设置QListWidgetItem大小
            item.setSizeHint(QSize(188, 35))
            # 调用上面的函数获取对应itemwidget
            widget = getMyListWidget(i["listName"], i["taskNum"], i["listColor"])
            # 添加item
            mainWindow.listWidget.addItem(item)
            # 为item设置widget
            mainWindow.listWidget.setItemWidget(item, widget)


    def showMyNoteOrNoteDirItem(data, root):

        """
        功能函数
        初始化界面，显示我的笔记列表
        :param data2: 我的笔记数据，从数据库中读入
        :param root: 当前的treewidget节点，用于递归
        """

        font = QFont()
        font.setFamily("黑体")
        font.setPointSize(8)
        font2 = QFont()
        font2.setFamily("黑体")
        font2.setPointSize(6)
        # 循环我的笔记列表数据，每一项都是字典
        for i in data:
            # 如果当前的每项数据都是列表，而且子项目内容不等于0的话，也就是还有子笔记
            if isinstance(i, dict) and len(i["subContent"]) != 0:
                # 添加一个节点
                child = QTreeWidgetItem(root)
                # 如果当前的节点不是根节点的
                if isinstance(root, QTreeWidget) == False:
                    # 非根节点，添加子节点
                    root.addChild(child)
                    # 如果是笔记文件的话
                    if i["isNote"]:
                        child.setSizeHint(0, QSize(130, 30))
                        child.setSizeHint(1, QSize(10, 30))
                        child.setSizeHint(2, QSize(10, 30))
                        child.setFont(0, font)
                        child.setText(0, i["noteName"])
                        child.setIcon(0, QIcon("./static/image/文件.svg"))
                    # 如果是笔记文件夹的话
                    elif i["isNote"] == False:
                        child.setSizeHint(0, QSize(130, 30))
                        child.setSizeHint(1, QSize(30, 30))
                        child.setSizeHint(2, QSize(30, 30))
                        child.setFont(0, font)
                        child.setFont(1, font)
                        child.setFont(2, font)
                        child.setText(0, i["noteName"])
                        # 设置为一个空格，标识是否为文件夹
                        child.setText(1, "    ")
                        child.setIcon(0, QIcon("./static/image/未打卡的文件夹.svg"))
                        url = "./static/image/" + addMyNoteOrNoteDirWindow.Add_NoteDir_Color_Flag
                        child.setIcon(2, QIcon(url))
                # 如果是根节点的话，就添加笔记或笔记本内容
                else:
                    if i["isNote"]:
                        child.setSizeHint(0, QSize(130, 30))
                        child.setSizeHint(1, QSize(10, 30))
                        child.setSizeHint(2, QSize(10, 30))
                        child.setFont(0, font)
                        child.setText(0, i["noteName"])
                        child.setIcon(0, QIcon("./static/image/文件.svg"))
                    elif i["isNote"] == False:
                        child.setSizeHint(0, QSize(130, 30))
                        child.setSizeHint(1, QSize(30, 30))
                        child.setSizeHint(2, QSize(30, 30))
                        child.setFont(0, font)
                        child.setFont(1, font)
                        child.setFont(2, font)
                        child.setText(0, i["noteName"])
                        child.setText(1, "    ")
                        child.setIcon(0, QIcon("./static/image/未打卡的文件夹.svg"))
                        url = "./static/image/" + addMyNoteOrNoteDirWindow.Add_NoteDir_Color_Flag
                        child.setIcon(2, QIcon(url))
                # 递归
                showMyNoteOrNoteDirItem(i["subContent"], child)
            # 如果没有当前的数据项没有子笔记的话，直接添加笔记或笔记本内容
            elif len(i["subContent"]) == 0:
                item = QTreeWidgetItem(root)
                if i["isNote"]:
                    item.setSizeHint(0, QSize(130, 30))
                    item.setSizeHint(1, QSize(10, 30))
                    item.setSizeHint(2, QSize(10, 30))
                    item.setFont(0, font)
                    item.setText(0, i["noteName"])
                    item.setIcon(0, QIcon("./static/image/文件.svg"))
                elif i["isNote"] == False:
                    item.setSizeHint(0, QSize(130, 30))
                    item.setSizeHint(1, QSize(30, 30))
                    item.setSizeHint(2, QSize(30, 30))
                    item.setFont(0, font)
                    item.setFont(1, font)
                    item.setFont(2, font)
                    item.setText(0, i["noteName"])
                    item.setText(1, "    ")
                    item.setIcon(0, QIcon("./static/image/未打卡的文件夹.svg"))
                    url = "./static/image/" + addMyNoteOrNoteDirWindow.Add_NoteDir_Color_Flag
                    item.setIcon(2, QIcon(url))


    def deleteNoteData(data):

        """
        功能函数
        删除选中的笔记文件，同时在笔记数据中查找到对应的文件，并用递归的方式删除
        :param data:笔记数据集合
        """

        delName = mainWindow.treeWidget.currentItem().text(0)
        # 四个空格，标记该数据为笔记本文件，非单个笔记文件
        if mainWindow.treeWidget.currentItem().text(1) == "    ":
            QMessageBox.information(addMyNoteOrNoteDirWindow.pushButton, "提示信息", "非笔记，请重新选择删除！")
        else:
            for i in data:
                print("-----------------\n", i)
                if i["isNote"] == True and i["noteName"] == delName and i["subContent"] == []:
                    data.remove(i)
                deleteNoteData(i["subContent"])


    def deleteNoteDirData(data):

        """
        功能函数
        删除选中的笔记本文件，同时在笔记数据中查找到对应的笔记文件夹，并用递归的方式删除
        :param data:笔记数据集合
        """

        delName = mainWindow.treeWidget.currentItem().text(0)
        # 四个空格，标记该数据为笔记本文件，非单个笔记文件
        if mainWindow.treeWidget.currentItem().text(1) == "    ":
            for i in data:
                if i["isNote"] == False and i["noteName"] == delName:
                    data.remove(i)
                deleteNoteDirData(i["subContent"])
        else:
            QMessageBox.information(addMyNoteOrNoteDirWindow.pushButton, "提示信息", "非笔记，请重新选择删除！")


    def renameNoteOrNoteDirData(data, rename, newname, isnote):

        """
        功能函数
        重命名选中的笔记或者笔记文件夹文件，采取递归的方式查找并修改数据
        :param data:笔记数据集合 rename: 需要重新命名的笔记或者文件夹 newname: 新名称 isnote：选中行中的文件夹标记，为4个空格
        """

        # 如果是笔记文件件的话
        if isnote == "    ":
            for i in data:
                # 如果没有子文件的话，直接修改名称
                if i["isNote"] == False and i["noteName"] == rename and i["subContent"] == []:
                    i["noteName"] = newname
                # 如果有子文件的话，需要把子文件数据中直接下一级的父文件夹信息也修改了
                elif i["isNote"] == False and i["noteName"] == rename and i["subContent"] != []:
                    i["noteName"] = newname
                    # 再把选中的文件夹下面对应一级的笔记文件的父文件夹修改为新名称
                    for a in i["subContent"]:
                        a["noteParent"] = newname
                renameNoteOrNoteDirData(i["subContent"], rename, newname, isnote)
        # 如果是笔记文件的话
        else:
            for i in data:
                if i["isNote"] == True and i["noteName"] == rename:
                    i["noteName"] = newname
                renameNoteOrNoteDirData(i["subContent"], rename, newname, isnote)


    def addNoteOrNoteDirData(data, newnoteornotedir):

        """
        功能函数
        :param data: 笔记数据集合 newnotedir: 传入新建的笔记文件夹数据
        """

        # 如果不存在父节点的话，就直接新建在根目录下
        if newnoteornotedir["noteParent"] == "":
            newnoteornotedir["index"] = len(data)
            data.append(newnoteornotedir)
        # 如果存在父节点的话
        else:
            for i in data:
                # 如果找到父节点的话，把新建的笔记文件夹数据插入到父节点的下一级数据中，然后跳出循环
                if i["noteName"] == newnoteornotedir["noteParent"]:
                    newnoteornotedir["index"] = len(i["subContent"])
                    i["subContent"].append(newnoteornotedir)
                    break
                # 否则就递归
                addNoteOrNoteDirData(i["subContent"], newnoteornotedir)


    def addDoneTaskItem(donetaskname):

        """
        功能函数
        点击清单，出现该清单对应的已完成的任务
        :param donetaskname: 已完成的任务名称
        """

        # 创建QListWidgetItem对象
        item = QListWidgetItem()
        # 设置QListWidgetItem大小
        item.setSizeHint(QSize(188, 35))
        # 将该任务添加至已完成的任务列表item
        widget = undoTaskChangeIntoDone(donetaskname)
        mainWindow.listWidget_3.addItem(item)
        mainWindow.listWidget_3.setItemWidget(item, widget)


    def addUndoTaskItem(undotaskname, undosubtasknum="", undotasklevel=""):

        """
        功能函数
        点击清单，出现该清单对应的未完成的任务
        :param: undotaskname 未完成的任务名称  undosubtasknum 子任务数量  undotasklevel 未完成任务等级
        """

        # 创建QListWidgetItem对象
        item = QListWidgetItem()
        # 设置QListWidgetItem大小
        item.setSizeHint(QSize(188, 35))
        # 将该任务添加至未完成任务列表的item中
        widget = getUndoTaskWidget(undotaskname, undosubtasknum, undotasklevel)
        mainWindow.listWidget_2.addItem(item)
        mainWindow.listWidget_2.setItemWidget(item, widget)


    def addUndoSubTaskItem(subtaskname):

        """
        功能函数
        点击某个任务，出现该任务下的未完成子任务
        :return:
        """

        global mainWindow

        # 控件
        widgetItem = QWidget()
        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)
        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()
        # 任务图标
        taskCheckBox = undoSubTaskCheckBox()
        # 任务名称
        taskName = MyQLineEdit(widgetItem)
        taskName.setFixedSize(150, 25)
        taskName.setText(subtaskname)
        # 任务删除标签
        taskDel = MyQPushButton(widgetItem)
        spacer = QSpacerItem(20, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)
        # 添加至水平布局
        layoutItem.setContentsMargins(5, 0, 5, 0)
        layoutMain.setContentsMargins(0, 0, 0, 0)
        layoutItem.addWidget(taskCheckBox)
        layoutItem.addWidget(taskName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(taskDel)
        layoutMain.addLayout(layoutItem)
        widgetItem.setStyleSheet(
            "QWidget{color: black; font: 8pt \"微软雅黑\";}"
        )
        # lineedit = widgetItem.findChildren(QLineEdit)[0]
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        # 创建QListWidgetItem对象
        item = QListWidgetItem()
        # 设置QListWidgetItem大小
        item.setSizeHint(QSize(188, 35))
        # 添加item
        mainWindow.listWidget_4.addItem(item)
        # 为item设置widget
        mainWindow.listWidget_4.setItemWidget(item, widgetItem)


    def undoSubTaskChangeIntoDone(undotaskname):

        """
        功能函数
        点击子任务复选框，未完成子任务变成已完成子任务
        """

        # 控件
        widgetItem = QWidget()

        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)

        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()

        # 任务图标
        taskCheckBox = doneSubTaskCheckBox()
        # 任务名称
        taskName = MyQLineEdit(widgetItem)
        taskName.setStyleSheet(
            "font: 10pt \"微软雅黑\"; "
            "background-color: rgb(127, 127, 127, 0);"
            "color: grey;"
            "border: None;"
        )
        taskName.setText(undotaskname)
        # 已完成任务的名称无法再编辑
        taskName.setEnabled(False)
        # 任务删除标签
        taskDel = MyQPushButton(widgetItem)
        spacer = QSpacerItem(20, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)
        # 添加至水平布局
        layoutItem.setContentsMargins(5, 0, 5, 0)
        layoutMain.setContentsMargins(0, 0, 0, 0)
        layoutItem.addWidget(taskCheckBox)
        layoutItem.addWidget(taskName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(taskDel)
        layoutMain.addLayout(layoutItem)
        widgetItem.setStyleSheet(
            "QWidget{color: black; font: 8pt \"微软雅黑\";}"
        )
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        return widgetItem


    def undoTaskChangeIntoDone(undotaskname):

        """
        功能函数
        添加我的清单中的自定义控件组件
        :param: undotaskname 自定义任务名称
        :return: widgetItem 自定义的清单控件
        """

        # 控件
        widgetItem = QWidget()

        # 总体上的全局水平布局
        layoutMain = QHBoxLayout(widgetItem)

        # 各个控件组成的水平布局
        layoutItem = QHBoxLayout()

        # 任务图标
        taskCheckBox = doneTaskCheckBox()
        # 任务名称
        taskName = QLabel()
        taskName.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        taskName.setText(undotaskname)
        taskName.resize(60, 16)
        # 子任务数量标签
        subTaskNum = QLabel()
        subTaskNum.setAlignment(Qt.AlignCenter)
        subTaskNum.setText("")
        # 任务程度
        taskLevel = QPushButton()
        taskLevel.setStyleSheet(
            "width: 13px;"
            "height: 13px;"
        )
        taskLevel.setText("")

        # 任务子菜单
        taskMenu = QLabel()
        taskMenu.setText("...")
        taskMenu.setAlignment(Qt.AlignCenter)
        spacer = QSpacerItem(60, 17, QSizePolicy.Expanding, QSizePolicy.Minimum)

        # 添加至水平布局
        layoutItem.setContentsMargins(5, 0, 5, 0)
        layoutMain.setContentsMargins(0, 0, 0, 0)
        layoutItem.addWidget(taskCheckBox)
        layoutItem.addWidget(taskName)
        layoutItem.addItem(spacer)
        layoutItem.addWidget(subTaskNum)
        layoutItem.addWidget(taskLevel)
        layoutItem.addWidget(taskMenu)
        layoutMain.addLayout(layoutItem)
        widgetItem.setStyleSheet(
            "QWidget{height: 80px; color: grey; font: 10pt \"黑体\";}"
        )
        widgetItem.setCursor(QCursor(Qt.PointingHandCursor))
        return widgetItem


    def doneTaskChangeIntoUndo(donetaskname, donesubtasknum="", donetasklevel=""):

        """
        功能函数
        添加任务展示界面，返回未完成任务列表项目
        :param donetaskname: 已完成任务名称
        :param donesubtasknum: 已完成任务子任务
        :param donetasklevel:  已完成任务等级
        :return: 未完成任务项目
        """

        widgetItem = getUndoTaskWidget(donetaskname, donesubtasknum, donetasklevel)
        return widgetItem


    def resetTaskDetailWidget():

        """
        功能函数
        重置任务详细界面内容
        """

        # 重置任务详细界面初始化内容
        # 重置子任务列表
        mainWindow.listWidget_4.clear()
        # 重置任务时间
        mainWindow.pushButton_7.setText("任务时间")
        # 重置任务重复
        mainWindow.pushButton_8.setText("")
        # 重置任务级别
        mainWindow.pushButton_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
            "color: black;"
        )
        mainWindow.pushButton_9.setText("任务级别")
        # 重置任务名称
        mainWindow.label_12.setText("任务名称")


    def exitApp():

        """
        功能函数
        点击系统托盘右键菜单退出，询问是否退出主应用
        """

        mainWindow.show()
        re = QMessageBox.question(mainWindow, "提示", "退出应用", QMessageBox.Yes |
                                  QMessageBox.No, QMessageBox.No)
        if re == QMessageBox.Yes:
            # 关闭窗体程序
            QCoreApplication.instance().quit()
            # 在应用程序全部关闭后，TrayIcon其实还不会自动消失，
            # 直到你的鼠标移动到上面去后，才会消失，
            # 这是个问题，（如同你terminate一些带TrayIcon的应用程序时出现的状况），
            # 这种问题的解决通过在程序退出前将其setVisible(False)来完成的。
            tp.setVisible(False)


    """槽函数集合"""


    def qAddMyListWindowShowToAdd():

        """
        槽函数
        显示清单添加窗口，同时主界面模态
        """

        qAddMyListWindow.setWindowModality(Qt.ApplicationModal)
        addMyListWindow.lineEdit.setFocus()
        qAddMyListWindow.setWindowTitle("添加清单")
        addMyListWindow.isModify = False
        qAddMyListWindow.show()


    def qAddMyListWindowShowToModify():

        """
        槽函数
        显示清单修改窗口，同时主界面模态
        """

        qAddMyListWindow.setWindowTitle("修改清单")
        qAddMyListWindow.setWindowModality(Qt.ApplicationModal)

        addMyListWindow.lineEdit.setFocus()
        addMyListWindow.isModify = True
        qAddMyListWindow.show()


    def qAddMyNoteOrNoteDirWindowShowToAdd():

        """
        槽函数
        显示笔记或者笔记本添加窗口，同时主界面模态
        """

        qAddMyNoteOrNoteDirWindow.setWindowModality(Qt.ApplicationModal)
        qAddMyNoteOrNoteDirWindow.setWindowTitle("添加笔记")
        addMyNoteOrNoteDirWindow.lineEdit.setFocus()
        # 同时将控件设置为显示
        addMyNoteOrNoteDirWindow.label.show()
        addMyNoteOrNoteDirWindow.label_1.show()
        addMyNoteOrNoteDirWindow.btn_1.show()
        addMyNoteOrNoteDirWindow.btn_2.show()
        addMyNoteOrNoteDirWindow.btn_3.show()
        addMyNoteOrNoteDirWindow.btn_4.show()
        addMyNoteOrNoteDirWindow.btn_5.show()
        addMyNoteOrNoteDirWindow.label_2.show()
        addMyNoteOrNoteDirWindow.comboBox.show()
        addMyNoteOrNoteDirWindow.isModify = False
        qAddMyNoteOrNoteDirWindow.show()


    def qAddMyNoteOrNoteDirWindowShowToModify():

        """
        槽函数
        显示笔记或者笔记本修改窗口，同时主界面模态
        """

        qAddMyNoteOrNoteDirWindow.setWindowTitle("修改名称")
        qAddMyNoteOrNoteDirWindow.setWindowModality(Qt.ApplicationModal)
        addMyNoteOrNoteDirWindow.lineEdit.setFocus()
        addMyNoteOrNoteDirWindow.isModify = True
        qAddMyNoteOrNoteDirWindow.show()


    def addOrModifyMyNoteOrNoteDir(data):

        """
        槽函数
        点击确认按钮，增加或者修改一个自定义的笔记或者笔记文件夹，同时清空输入框，并关闭窗口
        """

        global mainWindow, addMyNoteOrNoteDirWindow

        # 如果是新建功能的话
        if addMyNoteOrNoteDirWindow.isModify == False:
            myNoteOrNoteDirName = addMyNoteOrNoteDirWindow.lineEdit.text()
            font = QFont()
            font.setFamily("黑体")
            font.setPointSize(9)
            newNoteOrNoteDir = {
                "index": 0,
                "noteName": "",
                "isNote": None,
                "noteContent": "",
                "noteParent": "",
                "colorFlag": "",
                "subContent": [],
            }
            # 如果输入的自定义笔记名称为空的话
            if myNoteOrNoteDirName == "":
                QMessageBox.information(addMyNoteOrNoteDirWindow.pushButton, "提示信息", "空名称，请重新输入！")
            # 如果输入的自定义笔记名称过长的话
            elif len(myNoteOrNoteDirName.encode()) > 18:
                QMessageBox.information(addMyNoteOrNoteDirWindow.pushButton, "提示信息", "名称不超过12个字符")
            elif addMyNoteOrNoteDirWindow.comboBox.currentText() == "新建笔记":
                newNoteOrNoteDir["isNote"] = True
                # 如果是新建在选中的已经存在的文件夹之下的话
                if mainWindow.treeWidget.currentItem() and mainWindow.treeWidget.currentItem().text(1) != "":
                    # 就把新建的笔记放在当前的项目之下
                    item = QTreeWidgetItem(mainWindow.treeWidget.currentItem())
                    newNoteOrNoteDir["noteParent"] = mainWindow.treeWidget.currentItem().text(0)
                # 选中的在某个文件夹下的笔记，也就是选中的笔记存在父节点
                elif mainWindow.treeWidget.currentItem() and mainWindow.treeWidget.currentItem().parent():
                    # 就把新建的笔记也放在当前的父节点之下
                    item = QTreeWidgetItem(mainWindow.treeWidget.currentItem().parent())
                    newNoteOrNoteDir["noteParent"] = mainWindow.treeWidget.currentItem().parent().text(0)
                else:
                    # 否则就把新建的笔记放在根目录下
                    item = QTreeWidgetItem(mainWindow.treeWidget)
                    newNoteOrNoteDir["noteParent"] = ""
                # 设置图标及名称、其余空白2个列的大小、内容
                item.setSizeHint(0, QSize(90, 30))
                item.setSizeHint(1, QSize(30, 30))
                item.setSizeHint(2, QSize(30, 30))
                item.setFont(0, font)
                item.setText(0, myNoteOrNoteDirName)
                item.setToolTip(0, myNoteOrNoteDirName)
                item.setIcon(0, QIcon("./static/image/文件.svg"))
                # 添加新建的笔记文件数据
                newNoteOrNoteDir["noteName"] = myNoteOrNoteDirName
                addNoteOrNoteDirData(data, newNoteOrNoteDir)
            elif addMyNoteOrNoteDirWindow.comboBox.currentText() == "新建文件夹":
                newNoteOrNoteDir["isNote"] = False
                # 如果是新建在选中的已经存在的文件夹之下的话
                if mainWindow.treeWidget.currentItem() and mainWindow.treeWidget.currentItem().text(1) != "":
                    # 就把新建的文件夹放在当前的项目之下
                    item = QTreeWidgetItem(mainWindow.treeWidget.currentItem())
                    newNoteOrNoteDir["noteParent"] = mainWindow.treeWidget.currentItem().text(0)
                    # 选中的在某个文件夹下的笔记，也就是选中的笔记存在父节点，就放在父节点下
                elif mainWindow.treeWidget.currentItem() and mainWindow.treeWidget.currentItem().parent():
                    # 就把新建的笔记文件夹也放在当前的父节点之下
                    item = QTreeWidgetItem(mainWindow.treeWidget.currentItem().parent())
                    newNoteOrNoteDir["noteParent"] = mainWindow.treeWidget.currentItem().parent().text(0)
                else:
                    # 否则就把新建的笔记文件夹放在根目录下
                    item = QTreeWidgetItem(mainWindow.treeWidget)
                    newNoteOrNoteDir["noteParent"] = ""
                # 设置图标及名称、文件夹下内容数量、文件夹颜色区分3类列表大小、内容
                item.setSizeHint(0, QSize(130, 30))
                item.setSizeHint(1, QSize(30, 30))
                item.setSizeHint(2, QSize(30, 30))
                item.setFont(0, font)
                item.setFont(1, font)
                item.setFont(2, font)
                item.setText(0, myNoteOrNoteDirName)
                item.setToolTip(0, myNoteOrNoteDirName)
                item.setText(1, " ")
                item.setIcon(0, QIcon("./static/image/未打卡的文件夹.svg"))
                url = "./static/image/" + addMyNoteOrNoteDirWindow.Add_NoteDir_Color_Flag
                item.setIcon(2, QIcon(url))
                # 添加新建的笔记文件夹文件数据
                newNoteOrNoteDir["noteName"] = myNoteOrNoteDirName
                newNoteOrNoteDir["colorFlag"] = addMyNoteOrNoteDirWindow.Add_NoteDir_Color_Flag
                addNoteOrNoteDirData(data, newNoteOrNoteDir)
        # 如果是修改功能的话
        else:
            noteOrNoteDirName = mainWindow.treeWidget.currentItem().text(0)
            isNoteDir = mainWindow.treeWidget.currentItem().text(1)
            newName = addMyNoteOrNoteDirWindow.lineEdit.text()
            # 修改数据
            renameNoteOrNoteDirData(data, noteOrNoteDirName, newName, isNoteDir)
            mainWindow.treeWidget.currentItem().setText(0, newName)
        # 最后清空添加修改窗口的输入框内容，同时关闭窗口
        addMyNoteOrNoteDirWindow.lineEdit.clear()
        qAddMyNoteOrNoteDirWindow.close()
        QApplication.processEvents()


    def addOrModifyMyList(data):

        """
        槽函数
        点击确认按钮，增加一个条自定义清单，同时清空输入框，并关闭窗口，或者是修改一条清单内容
        """

        global mainWindow, addMyListWindow, qAddMyListWindow
        # 如果此时是执行的增加清单功能的话
        if addMyListWindow.isModify is False:
            myListName = addMyListWindow.lineEdit.text()
            # 如果输入的自定义清单名称为空的话
            if myListName == "":
                QMessageBox.information(addMyListWindow.pushButton, "提示信息", "空名称，请重新输入！")
            # 如果输入的自定义清单名称过长的话
            elif len(myListName.encode()) > 18:
                QMessageBox.information(addMyListWindow.pushButton, "提示信息", "名称不超过12个字符")
            else:
                # 创建QListWidgetItem对象
                item = QListWidgetItem()
                # 设置QListWidgetItem大小
                item.setSizeHint(QSize(188, 35))
                # 调用上面的函数获取对应itemWidget
                widget = getMyListWidget(myListName, "", addMyListWindow.Add_List_Color_Flag)
                # 添加item
                mainWindow.listWidget.addItem(item)
                # 为item设置widget
                mainWindow.listWidget.setItemWidget(item, widget)
                # 增加新建的清单数据
                newList = {
                    "index": len(data["list"]),
                    "listName": myListName,
                    "taskNum": 0,
                    "listColor": addMyListWindow.label_1.objectName(),
                    "task": [
                    ],
                }
                data["list"].append(newList)
        # 如果此时是执行修改清单功能的话
        elif addMyListWindow.isModify:
            item = mainWindow.listWidget.item(mainWindow.listIndex)
            mainWindow.listWidget.itemWidget(item).findChildren(QLabel)[1].setText(addMyListWindow.lineEdit.text())
            mainWindow.listWidget.itemWidget(item).findChildren(QPushButton)[0].setStyleSheet(
                "border-image: url('./static/image/" + addMyListWindow.label_1.objectName() + "');"
                                                                                              "color: rgb(127, 127, 127, 0);"
            )
            # 修改清单数据，找到当前选中清单的名称，将其修改为新的输入框中的名称
            for i in data["list"]:
                if i["listName"] == mainWindow.listWidget.itemWidget(item).findChildren(QLabel)[1].text():
                    i["listName"] = addMyListWindow.lineEdit.text()
                    i["listColor"] = addMyListWindow.label_1.objectName()
        addMyListWindow.lineEdit.clear()
        qAddMyListWindow.close()
        QApplication.processEvents()


    def addUndoTask(data):

        """
        槽函数
        在任务展示界面输入框中输入新的未完成任务，同时清空输入框
        """

        global mainWindow, Data
        undoTaskName = mainWindow.lineEdit.text()
        # 如果输入的自定义任务名称为空的话
        if undoTaskName == "":
            QMessageBox.information(mainWindow.lineEdit, "提示信息", "空名称，请重新输入！")
        # 如果输入的自定义任务名称过长的话
        elif len(undoTaskName.encode()) > 40:
            QMessageBox.information(mainWindow.lineEdit, "提示信息", "名称不超过40个字符")
        # 否则就是新增任务，对应不同的清单，添加Item的同时写入数据
        else:
            # 今日清单中没有任务数量显示
            if mainWindow.label_7.text() == "今日":
                for i in data["today"]:
                    if i["listName"] == mainWindow.label_7.text():
                        newTask = {
                            "index": len(i["task"]),
                            "taskCheck": True,
                            "taskName": mainWindow.lineEdit.text(),
                            "subTaskNum": "",
                            "taskLevel": "优先级清除.svg",
                            "taskTime": "",
                            "taskCircle": "",
                            "taskTags": [],
                            "taskDone": False,
                            "taskFlag": "无优先级",
                            "listParent": mainWindow.label_7.text(),
                            "subTask": []
                        }
                        i["task"].append(newTask)
                        # 创建QListWidgetItem对象
                        item = QListWidgetItem()
                        # 设置QListWidgetItem大小
                        item.setSizeHint(QSize(188, 35))
                        # 调用上面的函数获取对应
                        widget = getUndoTaskWidget(undoTaskName, newTask["subTaskNum"], newTask["taskLevel"])
                        # 添加item
                        mainWindow.listWidget_2.addItem(item)
                        # 为item设置widget
                        mainWindow.listWidget_2.setItemWidget(item, widget)
            # 最近七天清单中也没有任务数量显示
            elif mainWindow.label_7.text() == "最近7天":
                for i in data["recent"]:
                    if i["listName"] == mainWindow.label_7.text():
                        newTask = {
                            "index": len(i["task"]),
                            "taskCheck": True,
                            "taskName": mainWindow.lineEdit.text(),
                            "subTaskNum": "",
                            "taskLevel": "优先级清除.svg",
                            "taskTime": "",
                            "taskCircle": "",
                            "taskTags": [],
                            "taskDone": False,
                            "taskFlag": "无优先级",
                            "listParent": mainWindow.label_7.text(),
                            "subTask": []
                        }
                        i["task"].append(newTask)
                        # 创建QListWidgetItem对象
                        item = QListWidgetItem()
                        # 设置QListWidgetItem大小
                        item.setSizeHint(QSize(188, 35))
                        # 调用上面的函数获取对应
                        widget = getUndoTaskWidget(undoTaskName, newTask["subTaskNum"], newTask["taskLevel"])
                        # 添加item
                        mainWindow.listWidget_2.addItem(item)
                        # 为item设置widget
                        mainWindow.listWidget_2.setItemWidget(item, widget)
            # 清单列表中添加任务后，将数据中的任务数量加一，再重新赋值给清单列表
            else:
                for i in data["list"]:
                    if i["listName"] == mainWindow.label_7.text():
                        newTask = {
                            "index": len(i["task"]),
                            "taskCheck": True,
                            "taskName": mainWindow.lineEdit.text(),
                            "subTaskNum": "",
                            "taskLevel": "优先级清除.svg",
                            "taskTime": "",
                            "taskCircle": "",
                            "taskTags": [],
                            "taskDone": False,
                            "taskFlag": "无优先级",
                            "listParent": mainWindow.label_7.text(),
                            "subTask": []
                        }
                        i["task"].append(newTask)
                        i["taskNum"] = len(i["task"])
                        mainWindow.listWidget.itemWidget(mainWindow.listWidget.currentItem()).findChildren(QLabel)[
                            2].setText(str(i["taskNum"]))
                        # 创建QListWidgetItem对象
                        item = QListWidgetItem()
                        # 设置QListWidgetItem大小
                        item.setSizeHint(QSize(188, 35))
                        # 调用上面的函数获取对应
                        widget = getUndoTaskWidget(undoTaskName, newTask["subTaskNum"], newTask["taskLevel"])
                        # 添加item
                        mainWindow.listWidget_2.addItem(item)
                        # 为item设置widget
                        mainWindow.listWidget_2.setItemWidget(item, widget)
                        Data = data
            mainWindow.lineEdit.clear()
            mainWindow.lineEdit.setPlaceholderText("输入新的任务,按回车键添加")
        # 重置任务详细界面内容
        resetTaskDetailWidget()
        QApplication.processEvents()


    def showCurrentListTask(data):

        """
        槽函数
        点击我的清单中的一个，切换到清单界面
        """

        global mainWindow
        listName = mainWindow.listWidget.itemWidget(mainWindow.listWidget.item(
            mainWindow.listWidget.currentRow()
        )).findChildren(QLabel)[1].text()
        # 设置任务展示界面题头清单名称
        mainWindow.label_7.setText(listName)
        # 清空未完成和已完成任务列表中的任务
        mainWindow.listWidget_2.clear()
        mainWindow.listWidget_3.clear()
        # 重置任务详细界面内容
        resetTaskDetailWidget()
        # 查找数据中选中的清单下面的任务，并添加在未完成任务列表上
        # 如果是今日任务清单的话，就查找今日清单下的任务对应的任务详细信息
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["listParent"] == listName and i["taskDone"] == False:
                    addUndoTaskItem(i["taskName"], i["subTaskNum"], i["taskLevel"])
                elif i["listParent"] == listName and i["taskDone"] == True:
                    addDoneTaskItem(i["taskName"])
        # 如果是最近7天清单的话，就查找任务对应的任务详细信息
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["listParent"] == listName and i["taskDone"] == False:
                    addUndoTaskItem(i["taskName"], i["subTaskNum"], i["taskLevel"])
                elif i["listParent"] == listName and i["taskDone"] == True:
                    addDoneTaskItem(i["taskName"])
        # 如果是自定义的我的清单的话，就查找自定义清单下的任务对应的任务详细信息
        else:
            for i in data["list"]:
                if i["listName"] == listName:
                    for a in i["task"]:
                        if a["listParent"] == listName and a["taskDone"] == False:
                            addUndoTaskItem(a["taskName"], a["subTaskNum"], a["taskLevel"])
                        elif a["listParent"] == listName and a["taskDone"] == True:
                            addDoneTaskItem(a["taskName"])
        mainWindow.stackedWidget_2.setCurrentIndex(0)
        QApplication.processEvents()


    def undoTaskChanged(data):

        """
        槽函数
        点击任务前的复选框，该任务由未完成转变为已完成
        """

        global mainWindow

        # 获取信号发射出的控件也就是删除按钮相对于子任务列表的位置
        buttonpos = mainWindow.sender().mapToGlobal(QPoint(0, 0)) - mainWindow.listWidget_2.mapToGlobal(QPoint(0, 0))
        # 获取到item对象
        item = mainWindow.listWidget_2.indexAt(buttonpos)
        # 获取该对象的索引、对应的item
        index = item.row()
        delItem = mainWindow.listWidget_2.item(index)
        item = QListWidgetItem()
        item.setSizeHint(QSize(188, 35))
        # 获取对应的item中的任务名称
        taskName = mainWindow.listWidget_2.itemWidget(delItem).findChildren(QLabel)[0].text()
        # 更新该任务中的完成标记"taskDone"为True，同步将数据中的任务详细信息在未完成任务列表中进行显示
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == taskName:
                    i["taskDone"] = True
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == taskName:
                    i["taskDone"] = True
        else:
            for i in data["list"]:
                if i["listName"] == mainWindow.label_7.text():
                    for a in i["task"]:
                        if a["taskName"] == taskName:
                            a["taskDone"] = True
        # 将该任务添加至已完成的任务列表item
        widget = undoTaskChangeIntoDone(taskName)
        mainWindow.listWidget_3.addItem(item)
        mainWindow.listWidget_3.setItemWidget(item, widget)
        # 再讲该item在未完成任务列表中删除
        mainWindow.listWidget_2.takeItem(index)
        del delItem
        # 重置任务详细界面内容
        resetTaskDetailWidget()

        QApplication.processEvents()


    def doneTaskChanged(data):

        """
        槽函数
        点击任务前的复选框，该任务由已经完成转变为未完成
        """

        global mainWindow
        # 获取信号发射出的控件也就是删除按钮相对于子任务列表的位置
        buttonpos = mainWindow.sender().mapToGlobal(QPoint(0, 0)) - mainWindow.listWidget_3.mapToGlobal(QPoint(0, 0))
        # 获取到item对象
        item = mainWindow.listWidget_3.indexAt(buttonpos)
        # 获取该对象的索引、对应的item
        index = item.row()
        delItem = mainWindow.listWidget_3.item(index)
        item = QListWidgetItem()
        item.setSizeHint(QSize(188, 35))
        # 获取该item中的任务名称
        taskName = mainWindow.listWidget_3.itemWidget(delItem).findChildren(QLabel)[0].text()
        # 更新该任务中的完成标记"taskDone"为False
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == taskName:
                    i["taskDone"] = False
                    subTaskNum = i["subTaskNum"]
                    taskLevel = i["taskLevel"]
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == taskName:
                    i["taskDone"] = False
                    subTaskNum = i["subTaskNum"]
                    taskLevel = i["taskLevel"]
        else:
            for i in data["list"]:
                if i["listName"] == mainWindow.label_7.text():
                    for a in i["task"]:
                        if a["taskName"] == taskName:
                            a["taskDone"] = False
                            subTaskNum = a["subTaskNum"]
                            taskLevel = a["taskLevel"]
        # 将该任务添加至未完成任务列表的item中
        widget = doneTaskChangeIntoUndo(taskName, subTaskNum, taskLevel)
        mainWindow.listWidget_2.addItem(item)
        mainWindow.listWidget_2.setItemWidget(item, widget)
        # 再讲该任务在已完成列表中删除
        mainWindow.listWidget_3.takeItem(index)
        del delItem
        # 重置任务详细界面内容
        resetTaskDetailWidget()
        QApplication.processEvents()


    def undoSubTaskChanged():

        """
        槽函数
        点击子任务复选框，子任务完成，同时不恢复
        """

        # 获取信号发射出的控件也就是删除按钮相对于子任务列表的位置
        buttonpos = mainWindow.sender().mapToGlobal(QPoint(0, 0)) - mainWindow.listWidget_4.mapToGlobal(QPoint(0, 0))
        # 获取到item对象
        item = mainWindow.listWidget_4.indexAt(buttonpos)
        # 获取该对象的索引
        index = item.row()
        delItem = mainWindow.listWidget_4.item(index)
        # 获取对应的item中的任务名称
        undoSubTaskName = mainWindow.listWidget_4.itemWidget(delItem).findChildren(QLineEdit)[0].text()
        # 从子任务列表中删除该item
        mainWindow.listWidget_4.takeItem(index)
        del delItem
        # 创建QListWidgetItem对象
        item = QListWidgetItem()
        # 设置QListWidgetItem大小
        item.setSizeHint(QSize(188, 35))
        # 调用上面的函数获取对应
        widget = undoSubTaskChangeIntoDone(undoSubTaskName)
        # 添加item
        mainWindow.listWidget_4.addItem(item)
        # 为item设置widget
        mainWindow.listWidget_4.setItemWidget(item, widget)
        QApplication.processEvents()


    def addSubTaskByClicked(data):

        """
        槽函数
        点击任务详细界面中的添加子任务按钮，添加一条子任务
        """

        global mainWindow

        # 循环查找当前子任务列表中的所有的Item，存在空白子任务就停止使用添加子任务按钮
        for i in range(0, mainWindow.listWidget_4.count()):
            if mainWindow.listWidget_4.itemWidget(mainWindow.listWidget_4.item(i)).findChildren(QLineEdit)[
                0].text() == "":
                QMessageBox.information(mainWindow.label_14, "提示信息", "空名称，请重新输入子任务！")
                return
        if mainWindow.label_12.text() == "任务名称":
            pass
        else:
            mainWindow.label_13.setEnabled(True)
            # 创建QListWidgetItem对象
            item = QListWidgetItem()
            # 设置QListWidgetItem大小
            item.setSizeHint(QSize(188, 35))
            # 调用上面的函数获取对应
            widget = getSubTaskWidget()
            # 添加item
            mainWindow.listWidget_4.addItem(item)
            # 为item设置widget
            mainWindow.listWidget_4.setItemWidget(item, widget)
            lineedit = widget.findChildren(QLineEdit)[0]
            lineedit.setStyleSheet(
                "font: 10pt \"微软雅黑\"; "
                "background-color: rgb(127, 127, 127, 0);"
                "border: None;"
            )
            lineedit.setFocus()
            # 新增子任务数据
            if mainWindow.label_7.text() == "今日":
                for i in data["today"][0]["task"]:
                    if i["taskName"] == mainWindow.label_12.text():
                        newSubTask = {
                            "index": len(i["subTask"]),
                            "subTaskName": "",
                            "subTaskDoneState": False,
                            "taskParent": i["taskName"]
                        }
                        i["subTask"].append(newSubTask)
                        i["subTaskNum"] = len(i["subTask"])
                        mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(QLabel)[
                            1].setText(str(i["subTaskNum"]))
            elif mainWindow.label_7.text() == "最近7天":
                for i in data["recent"][0]["task"]:
                    if i["taskName"] == mainWindow.label_12.text():
                        newSubTask = {
                            "index": len(i["subTask"]),
                            "subTaskName": "",
                            "subTaskDoneState": False,
                            "taskParent": i["taskName"]
                        }
                        i["subTask"].append(newSubTask)
                        i["subTaskNum"] = len(i["subTask"])
                        mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(QLabel)[
                            1].setText(str(i["subTaskNum"]))
            else:
                for i in data["list"]:
                    for a in i["task"]:
                        if a["taskName"] == mainWindow.label_12.text():
                            newSubTask = {
                                "index": len(a["subTask"]),
                                "subTaskName": "",
                                "subTaskDoneState": False,
                                "taskParent": a["taskName"]
                            }
                            a["subTask"].append(newSubTask)
                            a["subTaskNum"] = len(a["subTask"])
                            mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                QLabel)[
                                1].setText(str(a["subTaskNum"]))


    def delSubTask(data):

        """
        槽函数
        点击右边的删除按钮，删除当前的子任务
        """

        global mainWindow

        # 获取信号发射出的控件也就是删除按钮相对于子任务列表的位置
        buttonpos = mainWindow.sender().mapToGlobal(QPoint(0, 0)) - mainWindow.listWidget_4.mapToGlobal(QPoint(0, 0))
        # 获取到item对象
        item = mainWindow.listWidget_4.indexAt(buttonpos)
        # 获取该对象的索引
        index = item.row()
        delItem = mainWindow.listWidget_4.item(index)
        delSubTaskName = mainWindow.listWidget_4.itemWidget(delItem).findChildren(QLineEdit)[0].text()
        # 从子任务列表中删除该item
        mainWindow.listWidget_4.takeItem(index)
        del delItem
        # 更新写入数据
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == mainWindow.label_12.text():
                    for b in i["subTask"]:
                        if b["subTaskName"] == delSubTaskName:
                            i["subTask"].remove(b)
                            i["subTaskNum"] = len(i["subTask"])
                            # 如果当前任务下的子任务已经是0了，就不显示
                            if i["subTaskNum"] == 0:
                                mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                    QLabel)[1].setText("")
                            else:
                                mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                    QLabel)[1].setText(str(i["subTaskNum"]))
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == mainWindow.label_12.text():
                    for b in i["subTask"]:
                        if b["subTaskName"] == delSubTaskName:
                            i["subTask"].remove(b)
                            i["subTaskNum"] = len(i["subTask"])
                            # 如果当前任务下的子任务已经是0了，就不显示
                            if i["subTaskNum"] == 0:
                                mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                    QLabel)[1].setText("")
                            else:
                                mainWindow.listWidget_2.itemWidget(mainWindow.listWidget_2.currentItem()).findChildren(
                                    QLabel)[1].setText(str(i["subTaskNum"]))
        else:
            for i in data["list"]:
                if i["listName"] == mainWindow.label_7.text():
                    for a in i["task"]:
                        if a["taskName"] == mainWindow.label_12.text():
                            for b in a["subTask"]:
                                if b["subTaskName"] == delSubTaskName:
                                    a["subTask"].remove(b)
                                    a["subTaskNum"] = len(a["subTask"])
                                    if a["subTaskNum"] == 0:
                                        mainWindow.listWidget_2.itemWidget(
                                            mainWindow.listWidget_2.currentItem()).findChildren(
                                            QLabel)[1].setText("")
                                    else:
                                        mainWindow.listWidget_2.itemWidget(
                                            mainWindow.listWidget_2.currentItem()).findChildren(
                                            QLabel)[1].setText(str(a["subTaskNum"]))
        QApplication.processEvents()


    def showTaskDetailWidgetByMyQLabel(index, data):

        """
        槽函数
        鼠标所在位置的当前的任务，出现该任务详细界面
        :param 当前鼠标所在行的索引值
        """

        global mainWindow
        item = mainWindow.listWidget_2.item(index)
        # 获取该item的任务名称并显示出来
        taskName = mainWindow.listWidget_2.itemWidget(item).findChildren(QLabel)[0].text()
        # 清空子任务列表中的子任务
        mainWindow.listWidget_4.clear()
        # 查找数据中对应的选中的当前任务下面的子任务，并添加在子任务列表上，同步显示名称、时间、重复、级别
        # 如果是今日任务清单的话，就查找今日清单下的任务对应的任务详细信息
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == taskName and i["taskDone"] is False:
                    # 标记任务日期设置界面内容
                    setTaskTimerWindow.taskIndex = str(i["index"])
                    if i["taskTime"] == "":
                        # 设置任务时间
                        mainWindow.pushButton_7.setText("任务时间")
                    else:
                        # 设置任务时间
                        mainWindow.pushButton_7.setText(i["taskTime"])
                    if i["taskCircle"] == "":
                        # 设置任务重复
                        mainWindow.pushButton_8.setText("")
                    else:
                        # 设置任务重复
                        mainWindow.pushButton_8.setText(i["taskCircle"])
                    # 循环添加该任务下的子任务控件
                    for a in i["subTask"]:
                        addUndoSubTaskItem(a['subTaskName'])
                    # 设置任务优先级，如果任务优先级为重要的话
                    if i["taskLevel"][3: 5] == "重要":
                        mainWindow.pushButton_9.setText("重要任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: red;"
                        )
                    # 如果任务优先级为中等的话
                    elif i["taskLevel"][3: 5] == "中等":
                        mainWindow.pushButton_9.setText("中等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #FFF635;"
                        )
                    # 如果任务优先级为次等的话
                    elif i["taskLevel"][3: 5] == "次等":
                        mainWindow.pushButton_9.setText("次等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #00ccff;"
                        )
                    # 如果任务无优先级的话
                    elif i["taskLevel"][3: 5] == "清除":
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: black;"
                        )
                        mainWindow.pushButton_9.setText("无优先级")
        # 如果是最近7天清单的话，就查找任务对应的任务详细信息
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == taskName and i["taskDone"] is False:
                    setTaskTimerWindow.taskIndex = str(i["index"])
                    if i["taskTime"] == "":
                        # 设置任务时间
                        mainWindow.pushButton_7.setText("任务时间")
                    else:
                        # 设置任务时间
                        mainWindow.pushButton_7.setText(i["taskTime"])
                    if i["taskCircle"] == "":
                        # 设置任务重复
                        mainWindow.pushButton_8.setText("")
                    else:
                        # 设置任务重复
                        mainWindow.pushButton_8.setText(i["taskCircle"])
                    # 循环添加该任务下的子任务控件
                    for a in i["subTask"]:
                        addUndoSubTaskItem(a['subTaskName'])
                    # 设置任务优先级，如果任务优先级为重要的话
                    if i["taskLevel"][3: 5] == "重要":
                        mainWindow.pushButton_9.setText("重要任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: red;"
                        )
                    # 如果任务优先级为中等的话
                    elif i["taskLevel"][3: 5] == "中等":
                        mainWindow.pushButton_9.setText("中等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #FFF635;"
                        )
                    # 如果任务优先级为次等的话
                    elif i["taskLevel"][3: 5] == "次等":
                        mainWindow.pushButton_9.setText("次等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #00ccff;"
                        )
                    # 如果任务无优先级的话
                    elif i["taskLevel"][3: 5] == "清除":
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: black;"
                        )
                        mainWindow.pushButton_9.setText("无优先级")
        # 如果是自定义的我的清单的话，就查找自定义清单下的任务对应的任务详细信息
        else:
            for i in data["list"]:
                if i["listName"] == mainWindow.label_7.text():
                    for a in i["task"]:
                        if a["taskName"] == taskName and a["taskDone"] is False:
                            setTaskTimerWindow.taskIndex = str(a["index"])
                            if a["taskTime"] == "":
                                # 设置任务时间
                                mainWindow.pushButton_7.setText("任务时间")
                            else:
                                # 设置任务时间
                                mainWindow.pushButton_7.setText(a["taskTime"])
                            if a["taskCircle"] == "":
                                # 设置任务重复
                                mainWindow.pushButton_8.setText("")
                            else:
                                # 设置任务重复
                                mainWindow.pushButton_8.setText(a["taskCircle"])
                            # 循环添加该任务下的子任务控件
                            for b in a["subTask"]:
                                addUndoSubTaskItem(b['subTaskName'])
                            # 设置任务优先级，如果任务优先级为重要的话
                            if a["taskLevel"][3: 5] == "重要":
                                mainWindow.pushButton_9.setText("重要任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: red;"
                                )
                            # 如果任务优先级为中等的话
                            elif a["taskLevel"][3: 5] == "中等":
                                mainWindow.pushButton_9.setText("中等任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: #FFF635;"
                                )
                            # 如果任务优先级为次等的话
                            elif a["taskLevel"][3: 5] == "次等":
                                mainWindow.pushButton_9.setText("次等任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: #00ccff;"
                                )
                            # 如果任务无优先级的话
                            elif a["taskLevel"][3: 5] == "清除":
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: black;"
                                )
                                mainWindow.pushButton_9.setText("无优先级")
        # 设置任务名称标签
        mainWindow.label_12.setText(taskName)
        setTaskTimerWindow.taskName = taskName
        QApplication.processEvents()


    def showTaskDetailWidgetByClicked(data):

        """
        槽函数
        点击当前清单中的一项任务，出现该任务详细界面，设置当前任务名称、时间、间隔、级别、重复、标签、描述和子任务列表
        :param 点击选中当前行的索引值
        """

        global mainWindow
        item = mainWindow.listWidget_2.currentItem()
        # 获取该item的任务名称并显示出来
        taskName = mainWindow.listWidget_2.itemWidget(item).findChildren(QLabel)[0].text()
        # 重置任务详细界面内容
        resetTaskDetailWidget()
        # 查找数据中对应的选中的当前任务下面的子任务，并添加在子任务列表上，同步显示名称、时间、重复、级别
        # 如果是今日任务清单的话，就查找今日清单下的任务对应的任务详细信息
        if mainWindow.label_7.text() == "今日":
            for i in data["today"][0]["task"]:
                if i["taskName"] == taskName and i["taskDone"] is False:
                    setTaskTimerWindow.taskIndex = str(i["index"])
                    if i["taskTime"] == "":
                        # 设置任务时间
                        mainWindow.pushButton_7.setText("任务时间")
                    else:
                        # 设置任务时间
                        mainWindow.pushButton_7.setText(i["taskTime"])
                    if i["taskCircle"] == "":
                        # 设置任务重复
                        mainWindow.pushButton_8.setText("")
                    else:
                        # 设置任务重复
                        mainWindow.pushButton_8.setText(i["taskCircle"])
                    # 循环添加该任务下的子任务控件
                    for a in i["subTask"]:
                        addUndoSubTaskItem(a['subTaskName'])
                    # 设置任务优先级，如果任务优先级为重要的话
                    if i["taskLevel"][3: 5] == "重要":
                        mainWindow.pushButton_9.setText("重要任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: red;"
                        )
                    # 如果任务优先级为中等的话
                    elif i["taskLevel"][3: 5] == "中等":
                        mainWindow.pushButton_9.setText("中等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #FFF635;"
                        )
                    # 如果任务优先级为次等的话
                    elif i["taskLevel"][3: 5] == "次等":
                        mainWindow.pushButton_9.setText("次等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #00ccff;"
                        )
                    # 如果任务无优先级的话
                    elif i["taskLevel"][3: 5] == "清除":
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: black;"
                        )
                        mainWindow.pushButton_9.setText("无优先级")
        # 如果是最近7天清单的话，就查找任务对应的任务详细信息
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"][0]["task"]:
                if i["taskName"] == taskName and i["taskDone"] is False:
                    setTaskTimerWindow.taskIndex = str(i["index"])
                    if i["taskTime"] == "":
                        # 设置任务时间
                        mainWindow.pushButton_7.setText("任务时间")
                    else:
                        # 设置任务时间
                        mainWindow.pushButton_7.setText(i["taskTime"])
                    if i["taskCircle"] == "":
                        # 设置任务重复
                        mainWindow.pushButton_8.setText("")
                    else:
                        # 设置任务重复
                        mainWindow.pushButton_8.setText(i["taskCircle"])
                    # 循环添加该任务下的子任务控件
                    for a in i["subTask"]:
                        addUndoSubTaskItem(a['subTaskName'])
                    # 设置任务优先级，如果任务优先级为重要的话
                    if i["taskLevel"][3: 5] == "重要":
                        mainWindow.pushButton_9.setText("重要任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: red;"
                        )
                    # 如果任务优先级为中等的话
                    elif i["taskLevel"][3: 5] == "中等":
                        mainWindow.pushButton_9.setText("中等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #FFF635;"
                        )
                    # 如果任务优先级为次等的话
                    elif i["taskLevel"][3: 5] == "次等":
                        mainWindow.pushButton_9.setText("次等任务")
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: #00ccff;"
                        )
                    # 如果任务无优先级的话
                    elif i["taskLevel"][3: 5] == "清除":
                        mainWindow.pushButton_9.setStyleSheet(
                            "background-color: rgb(255, 255, 255, 0);"
                            "font: 8pt \"微软雅黑\";"
                            "color: black;"
                        )
                        mainWindow.pushButton_9.setText("无优先级")
        # 如果是自定义的我的清单的话，就查找自定义清单下的任务对应的任务详细信息
        else:
            for i in data["list"]:
                if i["listName"] == mainWindow.label_7.text():
                    for a in i["task"]:
                        if a["taskName"] == taskName and a["taskDone"] is False:
                            setTaskTimerWindow.taskIndex = str(a["index"])
                            if a["taskTime"] == "":
                                # 设置任务时间
                                mainWindow.pushButton_7.setText("任务时间")
                            else:
                                # 设置任务时间
                                mainWindow.pushButton_7.setText(a["taskTime"])
                            if a["taskCircle"] == "":
                                # 设置任务重复
                                mainWindow.pushButton_8.setText("")
                            else:
                                # 设置任务重复
                                mainWindow.pushButton_8.setText(a["taskCircle"])
                            # 循环添加该任务下的子任务控件
                            for b in a["subTask"]:
                                addUndoSubTaskItem(b['subTaskName'])
                            # 设置任务优先级，如果任务优先级为重要的话
                            if a["taskLevel"][3: 5] == "重要":
                                mainWindow.pushButton_9.setText("重要任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: red;"
                                )
                            # 如果任务优先级为中等的话
                            elif a["taskLevel"][3: 5] == "中等":
                                mainWindow.pushButton_9.setText("中等任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: #FFF635;"
                                )
                            # 如果任务优先级为次等的话
                            elif a["taskLevel"][3: 5] == "次等":
                                mainWindow.pushButton_9.setText("次等任务")
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: #00ccff;"
                                )
                            # 如果任务无优先级的话
                            elif a["taskLevel"][3: 5] == "清除":
                                mainWindow.pushButton_9.setStyleSheet(
                                    "background-color: rgb(255, 255, 255, 0);"
                                    "font: 8pt \"微软雅黑\";"
                                    "color: black;"
                                )
                                mainWindow.pushButton_9.setText("无优先级")
        # 设置任务名称标签
        mainWindow.label_12.setText(taskName)
        setTaskTimerWindow.taskName = taskName
        QApplication.processEvents()


    def noteWriteWidgetShow():

        """
        槽函数
        点击我的笔记列表中的一条笔记，出现笔记编写界面
        """

        global mainWindow
        # TODO 需要下步完善
        # 如果点击的笔记文件夹的话，不做动作
        if mainWindow.treeWidget.currentItem().text(1) != "":
            pass
        # 否则点击的是笔记的话
        else:
            with open("1.md", 'r', encoding='utf-8') as f:
                mdcontent = f.read()
            mainWindow.label_15.setText(mainWindow.treeWidget.currentItem().text(0))
            mainWindow.textEdit.setText(mdcontent)
            mainWindow.stackedWidget_2.setCurrentIndex(1)


    def textChangedToShowByWeb():

        # TODO 还有进一步需要完善更多的支持功能
        import markdown
        global mainWindow
        html = markdown.markdown(mainWindow.textEdit.toPlainText(),
                                 extensions=['markdown.extensions.toc',
                                             'markdown.extensions.fenced_code',
                                             'markdown.extensions.tables',
                                             'markdown.extensions.admonition'])
        indexHtml = """<html lang="zh-cn">
                <head>
                    <meta content="text/html; charset=GBK" http-equiv="content-type" />
                    <link href="./css/default.css" rel="stylesheet">
                    <link href="./css/style.css" rel="stylesheet" type="text/css" />
                </head>
                <body>
                    <div> { content } </div>
                </body>
                </html>"""

        resHtml = indexHtml.replace("{ content }", html) or "jiji"
        with open("./static/index.html", 'w') as file_object:
            file_object.write(resHtml)
        # 需要放入页面的绝对地址，使用web方式解析html得到markdown预览
        mainWindow.textView.load(QUrl.fromLocalFile(QFileInfo("./static/index.html").absoluteFilePath()))


    def taskSubMenuWindowShow():

        """
        槽函数
        鼠标左键点击未完成任务列表中item的省略号标签，出现任务子菜单
        """

        qTaskSubMenuWindow.setWindowFlags(Qt.FramelessWindowHint)
        qTaskSubMenuWindow.show()
        taskSubMenuWindow.isShow = True


    def taskSubMenuWindowClose():

        """
        槽函数
        鼠标右击未完成任务列表中item的省略号标签，出现任务子菜单
        """

        qTaskSubMenuWindow.close()
        taskSubMenuWindow.isShow = False


    def setTaskTime(pushButtonName):

        """
        槽函数
        点击对应的功能键，设置当前任务不同的时间
        """

        # 如果任务日期设置在今天的话，就把任务时间标签设置为今天
        if pushButtonName == "pushButton":
            mainWindow.pushButton_7.setText((date.today() + timedelta(days=0)).strftime("%Y-%m-%d"))
        # 如果任务时间设置在明天的话
        elif pushButtonName == "pushButton_2":
            mainWindow.pushButton_7.setText((date.today() + timedelta(days=1)).strftime("%Y-%m-%d"))
        # 如果任务时间设置在下周的话
        elif pushButtonName == "pushButton_3":
            mainWindow.pushButton_7.setText((date.today() + timedelta(days=7)).strftime("%Y-%m-%d"))
        # 如果清除日期的话
        elif pushButtonName == "pushButton_4":
            mainWindow.pushButton_7.setText("无日期")
        else:
            pass
        qTaskSubMenuWindow.close()
        # currentItem = mainWindow.listWidget_2.item(taskSubMenuWindow.indexNum)
        # # 获取该item中的任务名称
        # taskName = mainWindow.listWidget_2.itemWidget(currentItem).findChildren(QLabel)[0].text()


    def setTaskLevel(pushButtonName):

        """
        槽函数
        点击对应的功能键
        :return:
        """

        currentItem = mainWindow.listWidget_2.item(taskSubMenuWindow.indexNum)
        taskLevel = mainWindow.listWidget_2.itemWidget(currentItem).findChildren(QPushButton)[0]

        # 如果任务优先级为重要的话
        if pushButtonName == "pushButton_5":
            mainWindow.pushButton_9.setText("重要任务")
            mainWindow.pushButton_9.setStyleSheet(
                "background-color: rgb(255, 255, 255, 0);"
                "font: 8pt \"微软雅黑\";"
                "color: red;"
            )
            taskLevel.setStyleSheet(
                "border-image: url('./static/image/listIcon/优先级重要.svg');"
                "width: 13px;"
                "height: 13px;"
            )
        # 如果任务优先级为中等的话
        elif pushButtonName == "pushButton_6":
            mainWindow.pushButton_9.setText("中等任务")
            mainWindow.pushButton_9.setStyleSheet(
                "background-color: rgb(255, 255, 255, 0);"
                "font: 8pt \"微软雅黑\";"
                "color: #FFF635;"
            )
            taskLevel.setStyleSheet(
                "border-image: url('./static/image/listIcon/优先级中等.svg');"
                "width: 13px;"
                "height: 13px;"
            )
        # 如果任务优先级为次等的话
        elif pushButtonName == "pushButton_7":
            mainWindow.pushButton_9.setText("次等任务")
            mainWindow.pushButton_9.setStyleSheet(
                "background-color: rgb(255, 255, 255, 0);"
                "font: 8pt \"微软雅黑\";"
                "color: #00ccff;"
            )
            taskLevel.setStyleSheet(
                "border-image: url('./static/image/listIcon/优先级次等.svg');"
                "width: 13px;"
                "height: 13px;"
            )
        # 如果任务无优先级的话
        elif pushButtonName == "pushButton_8":
            mainWindow.pushButton_9.setText("无优先级")
            mainWindow.pushButton_9.setStyleSheet(
                "background-color: rgb(255, 255, 255, 0);"
                "font: 8pt \"微软雅黑\";"
                "color: black;"
            )
            taskLevel.setStyleSheet(
                "border-image: url('./static/image/listIcon/优先级清除.svg');"
                "width: 13px;"
                "height: 13px;"
            )
        else:
            pass
        qTaskSubMenuWindow.close()


    def delTask(data):

        """
        槽函数
        点击删除任务按钮，删除当前任务，同时删除任务详细界面信息
        """

        # br 设置任务详细界面中的任务名称信息，不符合要求已丢弃不用
        # # 删除第一行的话，删除完后显示第二行任务名称
        # if mainWindow.listWidget_2.count() != 1 and taskSubMenuWindow.indexNum == 0:
        #     showTaskDetailWidgetByMyQLabel(taskSubMenuWindow.indexNum + 1)
        # # 删除最一行的话，删除完后显示倒数第二行任务名称
        # elif mainWindow.listWidget_2.count() != 1 and taskSubMenuWindow.indexNum == mainWindow.listWidget_2.count() - 1:
        #     showTaskDetailWidgetByMyQLabel(taskSubMenuWindow.indexNum - 1)
        # # 只有一行任务的话，删除完后显示无任务
        # elif mainWindow.listWidget_2.count() == 1:
        #     mainWindow.label_12.setText("无任务")
        # # 否则就删除一行，显示上一行任务名称
        # else:
        #     showTaskDetailWidgetByMyQLabel(taskSubMenuWindow.indexNum - 1)

        # 获取要删除行的item
        # 获取选中的行的索引值对应的itemWidget
        delItem = mainWindow.listWidget_2.item(taskSubMenuWindow.indexNum)
        taskName = mainWindow.listWidget_2.itemWidget(delItem).findChildren(QLabel)[0].text()
        # 更新对饮的清单中任务数量，也就是重新写入读取数据
        # 今日清单中没有任务数量显示
        if mainWindow.label_7.text() == "今日":
            pass
        # 最近七天清单中也没有任务数量显示
        elif mainWindow.label_7.text() == "最近7天":
            pass
        # 自定义清单列表中删除任务后，将数据中的任务数量减一，再重新赋值给清单列表
        else:
            for i in data["list"]:
                for a in i["task"]:
                    if a["taskName"] == taskName:
                        i["task"].remove(a)
                        i["taskNum"] = len(i["task"])
                        if i["taskNum"] == 0:
                            mainWindow.listWidget.itemWidget(mainWindow.listWidget.currentItem()).findChildren(QLabel)[
                                2].setText("")
                        else:
                            mainWindow.listWidget.itemWidget(mainWindow.listWidget.currentItem()).findChildren(QLabel)[
                                2].setText(str(i["taskNum"]))
        # 从任务列表中删除该item
        mainWindow.listWidget_2.takeItem(taskSubMenuWindow.indexNum)
        del delItem
        # 删除任务详细界面初始化内容
        # 删除子任务列表
        mainWindow.listWidget_4.clear()
        # 删除任务时间
        mainWindow.pushButton_7.setText("任务时间")
        # 删除任务重复
        mainWindow.pushButton_8.setText("")
        # 删除任务级别
        mainWindow.pushButton_9.setStyleSheet(
            "background-color: rgb(255, 255, 255, 0);"
            "font: 8pt \"微软雅黑\";"
            "color: black;"
        )
        mainWindow.pushButton_9.setText("任务级别")
        # 删除任务名称
        mainWindow.label_12.setText("任务名称")
        qTaskSubMenuWindow.close()
        QApplication.processEvents()


    def renameListRightContext(data):

        """
        槽函数
        点击清单列表中的重命名清单按钮，出现重命名清单窗口，并将当前清单内容设置到重命名清单窗口中
        """

        item = mainWindow.listWidget.item(mainWindow.listIndex)
        listName = mainWindow.listWidget.itemWidget(item).findChildren(QLabel)[1].text()
        addMyListWindow.lineEdit.setText(listName)
        for i in data["list"]:
            if i["listName"] == mainWindow.listWidget.itemWidget(item).findChildren(QLabel)[1].text():
                addMyListWindow.label_1.setStyleSheet(
                    "border-image: url('./static/image/" + i["listColor"] + "');"
                )
        qAddMyListWindowShowToModify()


    def deleteListRightContext(data):

        """
        槽函数
        点击清单列表中的删除清单按钮，删除当前清单，同时默认显示今日清单中的内容任务
        """

        delItem = mainWindow.listWidget.item(mainWindow.listIndex)
        delListName = mainWindow.listWidget.itemWidget(delItem).findChildren(QLabel)[1].text()
        mainWindow.listWidget.takeItem(mainWindow.listIndex)
        del delItem
        # 删除清单数据
        for i in data["list"]:
            if i["listName"] == delListName:
                data["list"].remove(i)
        # 删除后重命名清单索引，也就是将索引重新按照顺序排序命名
        for i in data["list"]:
            i["index"] = data["list"].index(i)

        # 删除完成后显示今日清单内容
        showTodayTaskItem(Data)


    def myListRightContext(pos):

        """
        槽函数
        点击创建的清单列表中每一项歌单，出现右击菜单
        """

        # 查看右键时是否在item上面,如果不在.就不显示右击菜单
        if mainWindow.listWidget.itemAt(pos):
            popMenu = QMenu()
            popMenu.setStyleSheet(
                ".QMenu {"
                "background-color: white;"
                "color: black;"
                "font: 8pt  \'微软雅黑\' ;"
                "width: 55px; height: 40px;"
                "padding: 0 0 0 0;"
                "margin: 0 5px 0 0;"
                "text-align: center;"
                "}"
                ".QMenu:item::selected {"
                "background-color: grey;"
                "font: 8pt  \'微软雅黑\' ;"
                "width: 55px; height: 40px;"
                "margin: 0 5px 0 0;"
                "padding: 0 0 0 5px;"
                "text-align: center;"
                "}"
            )
            renameAct = QAction('编辑清单', mainWindow.listWidget)
            delAct = QAction("删除清单", mainWindow.listWidget)
            item = mainWindow.listWidget.indexAt(pos)
            index = item.row()
            mainWindow.listIndex = index
            listItem = mainWindow.listWidget.item(index)
            popMenu.addAction(renameAct)
            popMenu.addAction(delAct)
            renameAct.triggered.connect(partial(renameListRightContext, Data))
            delAct.triggered.connect(partial(deleteListRightContext, Data))
            popMenu.exec_(mainWindow.listWidget.mapToGlobal(pos))


    def qSetTaskTimerWindowShow():

        """
        槽函数
        点击任务时间按钮，出现任务时间、重复间隔设置界面
        """

        if setTaskTimerWindow.isShow:
            qSetTaskTimerWindow.close()
            setTaskTimerWindow.isShow = False
        # 只要是选中了任务，就可以进行时间设置
        elif setTaskTimerWindow.isShow is False and mainWindow.label_12.text() != "任务名称":
            qSetTaskTimerWindow.move(mainWindow.pushButton_7.mapToGlobal(QPoint(0, mainWindow.pushButton_7.height())))
            qSetTaskTimerWindow.setWindowModality(Qt.ApplicationModal)
            setTaskTimerWindow.oldTime = mainWindow.pushButton_7.text()
            qSetTaskTimerWindow.show()
            setTaskTimerWindow.isShow = True


    def renameNoteOrNoteDirRightContext():

        """
        槽函数
        点击笔记列表中的重命名按钮，出现重命名笔记窗口，并将当前清单内容设置到重命名清单窗口中
        """

        noteOrNoteDirName = mainWindow.treeWidget.currentItem().text(0)
        addMyNoteOrNoteDirWindow.lineEdit.setText(noteOrNoteDirName)
        if mainWindow.treeWidget.currentItem().text(1) == "    ":
            addMyNoteOrNoteDirWindow.label.show()
            addMyNoteOrNoteDirWindow.label_1.show()
            addMyNoteOrNoteDirWindow.btn_1.show()
            addMyNoteOrNoteDirWindow.btn_2.show()
            addMyNoteOrNoteDirWindow.btn_3.show()
            addMyNoteOrNoteDirWindow.btn_4.show()
            addMyNoteOrNoteDirWindow.btn_5.show()
        else:
            addMyNoteOrNoteDirWindow.label.hide()
            addMyNoteOrNoteDirWindow.label_1.hide()
            addMyNoteOrNoteDirWindow.btn_1.hide()
            addMyNoteOrNoteDirWindow.btn_2.hide()
            addMyNoteOrNoteDirWindow.btn_3.hide()
            addMyNoteOrNoteDirWindow.btn_4.hide()
            addMyNoteOrNoteDirWindow.btn_5.hide()
        addMyNoteOrNoteDirWindow.label_2.hide()
        addMyNoteOrNoteDirWindow.comboBox.hide()
        qAddMyNoteOrNoteDirWindowShowToModify()


    def moveNoteOrNoteDirRightContext(data):
        # 需要下步完善
        pass


    def deleteNoteRightContext(data):

        """
        槽函数
        选中我的笔记中的某个笔记
        :param data: 笔记数据集合
        """

        # 递归删除数据中查找到的笔记文件
        deleteNoteData(data)
        # 清空我的笔记列表
        mainWindow.treeWidget.clear()
        # 将删除后的新的笔记数据全部显示在我的笔记列表里面
        showMyNoteOrNoteDirItem(data, mainWindow.treeWidget)


    def deleteNoteDirRightContext(data):

        """
        槽函数
        选中我的笔记中的某个笔记本
        :param data: 笔记数据集合
        """

        # 递归删除数据中查找到的笔记本文件
        deleteNoteDirData(data)
        # 清空我的笔记列表
        mainWindow.treeWidget.clear()
        # 将删除后的新的笔记数据全部显示在我的笔记列表里面
        showMyNoteOrNoteDirItem(data, mainWindow.treeWidget)


    def myNoteOrNoteDirRightContext(pos):

        """
        槽函数
        点击创建的清单列表中每一项歌单，出现右击菜单
        :param pos: 鼠标的QPoint位置
        """

        # 查看右键时是否在item上面,如果不在.就不显示右击菜单
        if mainWindow.treeWidget.itemAt(pos):
            popMenu = QMenu()
            popMenu.setStyleSheet(
                ".QMenu {"
                "background-color: white;"
                "color: black;"
                "font: 8pt  \'微软雅黑\' ;"
                "width: 55px; height: 60px;"
                "padding: 0 0 0 0;"
                "margin: 0 5px 0 0;"
                "text-align: center;"
                "}"
                ".QMenu:item::selected {"
                "background-color: grey;"
                "font: 8pt  \'微软雅黑\' ;"
                "width: 55px; height: 60px;"
                "padding: 0 0 0 5px;"
                "margin: 0 5px 0 0;"
                "text-align: center;"
                "}"
            )
            renameAct = QAction('编      辑', mainWindow.treeWidget)
            delNoteAct = QAction("删除笔记", mainWindow.treeWidget)
            delDirAct = QAction("删除文件夹", mainWindow.treeWidget)
            moveAct = QAction("移      动", mainWindow.treeWidget)
            item = mainWindow.treeWidget.indexAt(pos)
            index = item.row()
            mainWindow.noteIndex = index
            popMenu.addAction(renameAct)
            popMenu.addAction(delNoteAct)
            popMenu.addAction(delDirAct)
            popMenu.addAction(moveAct)
            renameAct.triggered.connect(partial(renameNoteOrNoteDirRightContext))
            moveAct.triggered.connect(partial(moveNoteOrNoteDirRightContext, DataNote["note"]))
            delNoteAct.triggered.connect(partial(deleteNoteRightContext, DataNote["note"]))
            delDirAct.triggered.connect(partial(deleteNoteDirRightContext, DataNote["note"]))
            popMenu.exec_(mainWindow.treeWidget.mapToGlobal(pos))


    def qSetTaskTimerWindowClose():

        """
        槽函数
        点击时间设置界面取消按钮，关闭时间设置界面，同时重置标识符
        """

        setTaskTimerWindow.isShow = False
        qSetTaskTimerWindow.close()


    def setTaskTimer(data):

        """
        槽函数
        选中任务时间设置界面内容，写入数据
        """

        newTaskTime = setTaskTimerWindow.timerYearMonthDay + " " + setTaskTimerWindow.timerWeekday + \
            " " + setTaskTimerWindow.timerTime
        # 更新数据
        # 今日清单
        if mainWindow.label_7.text() == "今日":
            for i in data["today"]:
                for a in i["task"]:
                    if a["index"] == int(setTaskTimerWindow.taskIndex) and \
                            a["taskName"] == setTaskTimerWindow.taskName:
                        print("----------", a)
                        a["taskTime"] = newTaskTime
                        print("----------", a)
        # 最近七天清单
        elif mainWindow.label_7.text() == "最近7天":
            for i in data["recent"]:
                for a in i["task"]:
                    if a["index"] == int(setTaskTimerWindow.taskIndex) and \
                            a["taskName"] == setTaskTimerWindow.taskName:
                        print("----------", a)
                        a["taskTime"] = newTaskTime
                        print("----------", a)
        # 自定义清单列表中删除任务后，将数据中的任务数量减一，再重新赋值给清单列表
        else:
            for i in data["list"]:
                for a in i["task"]:
                    if a["index"] == int(setTaskTimerWindow.taskIndex) and \
                            a["taskName"] == setTaskTimerWindow.taskName:
                        print("----------", a)
                        a["taskTime"] = newTaskTime
                        print("----------", a)
        mainWindow.pushButton_7.setText(newTaskTime)
        qSetTaskTimerWindow.close()


    def tpAct(reason):

        """
        槽函数
        点击系统托盘图标，显示程序主界面
        :param reason: 鼠标点击icon传递的信号会带有一个整形的值，1是表示单击右键，2是双击，3是单击左键，4是用鼠标中键点击
        """

        if reason == 2 or reason == 3:
            mainWindow.show()


    """信号与槽函数集合"""

    # 点击今日清单，出现任务展示界面内容
    mainWindow.pushButton_4.clicked.connect(partial(showTodayTaskItem, Data))
    # 点击最近七日清单，出现任务展示界面内容
    mainWindow.pushButton_5.clicked.connect(partial(showRecentTaskItem, Data))
    # 点击我的清单中自定义的清单，清单名称标签、未完成任务和已完成任务会变换
    mainWindow.listWidget.itemClicked.connect(partial(showCurrentListTask, Data))
    # 点击新建清单按钮，出现创建清单界面
    mainWindow.pushButton_6.clicked.connect(qAddMyListWindowShowToAdd)
    # 点击新建清单界面中的取消按钮，创建清单界面消失
    addMyListWindow.pushButton_2.clicked.connect(qAddMyListWindow.close)
    # 点击新建清单界面中的确认按钮或者按下回车键，增加一条自定义的清单，或者修改一条清单
    addMyListWindow.pushButton.clicked.connect(partial(addOrModifyMyList, Data))
    addMyListWindow.lineEdit.returnPressed.connect(partial(addOrModifyMyList, Data))
    # 点击我的笔记新建下拉选项，出现新建笔记或者新建文件夹界面
    mainWindow.pushButton_comboBox.clicked.connect(qAddMyNoteOrNoteDirWindowShowToAdd)
    # 点击新建笔记界面中的确认按钮或者按下回车键，增加一条自定义的笔记或者修改笔记
    addMyNoteOrNoteDirWindow.pushButton.clicked.connect(partial(addOrModifyMyNoteOrNoteDir, DataNote["note"]))
    addMyNoteOrNoteDirWindow.lineEdit.returnPressed.connect(partial(addOrModifyMyNoteOrNoteDir, DataNote["note"]))
    # 点击新建笔记界面中的取消按钮，新建笔记界面消失
    addMyNoteOrNoteDirWindow.pushButton_2.clicked.connect(qAddMyNoteOrNoteDirWindow.close)
    # 输入新的任务后，按下回车键添加当前清单里面的新任务，同步增加数据
    mainWindow.lineEdit.returnPressed.connect(partial(addUndoTask, Data))
    # 右击创建的自定义清单，出现右键菜单
    mainWindow.listWidget.customContextMenuRequested[QPoint].connect(myListRightContext)
    # 点击当前清单未完成的任务，最右侧任务详细界面出现对应的信息
    mainWindow.listWidget_2.itemClicked.connect(partial(showTaskDetailWidgetByClicked, Data))
    # 点击任务详细界面增加子任务按钮，新建一条子任务，同步增加数据
    mainWindow.label_13.clicked.connect(partial(addSubTaskByClicked, Data))
    # 点击我的笔记列表中的一条笔记，出现笔记编写界面
    mainWindow.treeWidget.itemClicked.connect(noteWriteWidgetShow)
    # 右击创建的自定义笔记或者笔记文件夹，出现右键菜单
    mainWindow.treeWidget.customContextMenuRequested[QPoint].connect(myNoteOrNoteDirRightContext)
    # MarkDown编辑器输入文字，右侧的预览器进行实时展示
    mainWindow.textEdit.textChanged.connect(textChangedToShowByWeb)
    # 任务子菜单信号动作, 点击日期按钮，设置当前任务时间，同时使用partial方法传入的当前按钮名称作为槽函数参数
    taskSubMenuWindow.pushButton.clicked.connect(partial(setTaskTime, taskSubMenuWindow.pushButton.objectName()))
    taskSubMenuWindow.pushButton_2.clicked.connect(partial(setTaskTime, taskSubMenuWindow.pushButton_2.objectName()))
    taskSubMenuWindow.pushButton_3.clicked.connect(partial(setTaskTime, taskSubMenuWindow.pushButton_3.objectName()))
    taskSubMenuWindow.pushButton_4.clicked.connect(partial(setTaskTime, taskSubMenuWindow.pushButton_4.objectName()))
    # 任务子菜单信号动作, 点击优先级按钮，设置当前任务优先级，同时使用partial方法传入的当前按钮名称作为槽函数参数
    taskSubMenuWindow.pushButton_5.clicked.connect(partial(setTaskLevel, taskSubMenuWindow.pushButton_5.objectName()))
    taskSubMenuWindow.pushButton_6.clicked.connect(partial(setTaskLevel, taskSubMenuWindow.pushButton_6.objectName()))
    taskSubMenuWindow.pushButton_7.clicked.connect(partial(setTaskLevel, taskSubMenuWindow.pushButton_7.objectName()))
    taskSubMenuWindow.pushButton_8.clicked.connect(partial(setTaskLevel, taskSubMenuWindow.pushButton_8.objectName()))
    # 任务子菜单信号动作，点击删除按钮，删除清单中的当前任务，同步删除数据
    taskSubMenuWindow.pushButton_11.clicked.connect(partial(delTask, Data))
    # 点击任务详情界面时间设置，出现时间设置界面
    mainWindow.pushButton_7.clicked.connect(qSetTaskTimerWindowShow)
    # 点击时间设置界面确定按钮，添加当前选中的任务时间
    setTaskTimerWindow.pushButton_3.clicked.connect(partial(setTaskTimer, Data))
    # setTaskTimerWindow.calendarWidget.clicked[QDate].connect(setTaskTimer)
    # 点击时间设置界面取消按钮，时间设置界面关闭
    setTaskTimerWindow.pushButton_4.clicked.connect(qSetTaskTimerWindowClose)

    # 初始化从数据库中读取到的数据，并显示
    showTodayTaskItem(Data)

    # 初始化从数据库中读取到的数据，展示我的清单列表
    showMyListItem(Data)

    # 初始化从数据库读取到的数据，展示我的笔记列表
    showMyNoteOrNoteDirItem(DataNote["note"], mainWindow.treeWidget)

    # 显示主界面
    mainWindow.show()

    """系统托盘后台运行"""

    # 在系统托盘处显示图标
    tp = QSystemTrayIcon(mainWindow)
    tp.setIcon(QIcon('ico.png'))
    # 设置系统托盘图标的菜单
    showMainWindowAction = QAction('&显示(Show)', triggered=mainWindow.show)
    exitMainWindowAction = QAction('&退出(Exit)', triggered=exitApp)
    tpMenu = QMenu()
    # 设置系统托盘右击选项样式
    tpMenu.setStyleSheet(
        ".QMenu {"
        "background-color: white;"
        "color: black;"
        "font: 6pt  \'微软雅黑\' ;"
        "width: 55px; height: 40px;"
        "padding: 0 0 0 5px;"
        "text-align: center;"
        "}"
        ".QMenu:item::selected {"
        "background-color: white;"
        "font: 6pt  \'微软雅黑\' ;"
        "width: 55px; height: 40px;"
        "padding: 0 0 0 5px;"
        "text-align: center;"
        "}"
    )
    tpMenu.addAction(showMainWindowAction)
    tpMenu.addAction(exitMainWindowAction)
    tp.setContextMenu(tpMenu)
    # 添加点击系统托盘图标的信号
    tp.activated.connect(tpAct)
    # 不调用show不会显示系统托盘
    tp.show()

    # 信息提示
    # 参数1：标题
    # 参数2：内容
    # 参数3：图标（0没有图标 1信息图标 2警告图标 3错误图标），0还是有一个小图标
    # tp.showMessage('tp', 'tpContent', icon=1)
    # def message():
    #     print("弹出的信息被点击了")
    # tp.messageClicked.connect(message)

    sys.exit(app.exec_())

# TODO 该项目还有几个内容要实现：
# TODO    二是我的笔记右键移动功能
# TODO    三是系统设置界面调整
# TODO    四是使用MongoDB数据库读取和写入功能
# TODO    五是MarkDown编辑器完善功能
# TODO    六是用户登录界面功能、数据同步功能
# TODO    八是视情况完成软件更新功能
# TODO    九是使用Nuitka打包
